javascript - Using a string as a parameter in requirejs text plugin -


i wanted use string within require , load handlebar template file.

"invalid require call : notloaded",'module name "'+i+'" has not been loaded yet context:"


define(function( require) {    var gettemplatefile = function(templatename) {      return require(['text!../html/templates/header.tpl']);   /* works */   }  });   //string concatenated define(function( require) {    var gettemplatefile = function(templatename) {      return require(['text!../html/templates/'+templatename+'.tpl']);   /* not work */   }  }); 

i followed workaround given here ( requirejs text plugin , variable concatenated string ) still got same error. in getting working.

you misusing require function. see here spec. you'll want use require(string) (along array version) or require(array, function) depending on want achieve. answer linked uses array variation.


Comments

Popular posts from this blog

Change php variable from jquery value using ajax (same page) -

Pull out data related to my apps from Android Play Store and iOS App Store -

How can I fetch data from a web server in an android application? -