WebStorm: Using Backbone.js
Hi,
I am using WebStorm to help learn Javascript. I'd like to work with Backbone.js (http://backbonejs.org/) (nainly the collection function) but I can't figure out how to use it with WebStorm.
I have a project that contains a single javascript file (test.js). I've gone into the project's settings (Settings -> Languages & Frameworks -> JavaScript -> Libraries) and added the Backbone.js file I downloaded from here.
How do I now use Backbone.js in the test.js file I created?
Thank you!!
-CS
Attachment(s):
Screen Shot 2015-02-18 at 12.27.30 PM.png
请先登录再写评论。
Hmm... Not sure I follow you. What do you expect to see? Libraries are only used for code completion/type hinting, you can't expect any code being generated for you after adding a library. Note also that WebStorm doesn't provide any special support for Backbone, for example, it doesn't recognize its inheritance pattern, etc.
Apologies... I am very new to javascript (but not software development). I also refered to the wrong file by mistake in my post: I meant Underscore.js, not Backbone.js.
I had expected to be able to "import" one js file into another (like the way #include works in C++) but have discovered that that isn't the case.
So, if I launch WebSphere, create a new (empty) project, and add a new javascript source file to the project, how can I use Backbone in the code I write in that file?
I'd like to be able to make calls like this in the new file:
// Reduce is an Underscore.js function
var sum = _.reduce([1, 2, 3], function(memo, num){ return memo + num; }, 0);Is there no way to do this in WebStorm?
Thank you again for your time,
-CS
Yes - you need to do exactly the same things as you would do when using any other IDE (or simple text editor): enter your Underscore.js code in your new .js file, then create a new HTML file, add links for both Underscore.js and your file to this HTML - that's all. Like:
<script src="./underscore.js"></script>
<script src="./test.js"></script>
You are awesome Elena - thank you!