简体   繁体   中英

Unexpected behavoiur of define of requirejs

This code is working

define([
  'jquery',
  'underscore',
  'backbone'
], function($, _, Backbone,home_template) {
    var HomeView = Backbone.View.extend({    
        render: function() {  
            alert('abcd');
        }
    });

    return HomeView;  
});

this code is not working

define([
  'jquery',
  'underscore',
  'backbone',
  'text!modules/home/home_template.html'
], 
function($, _, Backbone,home_template) {
    var HomeView = Backbone.View.extend({    
        render: function() {  
            alert('abcd');
        }
    });  
    return HomeView;  
});

My directory structure is like webroot/modules/home/home_template.html

What can be the problem ??

Thanks

Problem might be in two possible places:

1) Error in path(u can check in in fireBug or any other tool in network tab, look for 404 errors). It might be template or some other scripts placed inn wrong folder.

2) Error in template syntax - in case of underscore be sure your template wrapped in <script type="template"> .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM