D
D
dissdoc2015-02-26 20:58:11
backbone.js
dissdoc, 2015-02-26 20:58:11

How to fix unstable module loading in RequireJS?

Hello. There is such a simple pseudo-code (I often use it in my project)

require(['MyView', 'MyCollection'], function(View, Collection) {
    var collection = new Collection,
          view = new View({collection: collection});
 
    // каким-либо образом загружаем данные во view
   collection.fetch().done(function() {
       $('wrapper').html(view.render().el);
   });
});

So, the problem is that it happens that this piece of code is not loaded. An example of work is as follows
1. I go to the page
2. This view appears
3. I press F5
4. The view did not appear
5. I press F5 again
6. The view appeared
I.e. work is unpredictable. How to deal with it?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
K
Konstantin Kitmanov, 2015-02-26
@dissdoc

It never happened that require.js didn't load something. Are you sure that the problem is in the loading of the modules, and not in the fact that you collection.fetch()received 500 from the server? What is visible in the console?

D
dissdoc, 2015-02-28
@dissdoc

Yes, I found errors in the logic. Now I've cleaned everything up.
Works more stable

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question