Title: puremvc with requirejs and or nodejs. Post by: drr00t on June 21, 2012, 08:43:16 Hi,
I have use Backbone with requirejs to load templates, i was news native port for greate puremvc architecture, and i trying replace Backbone. I try load with requirejs but i couldn't. There is any way to add something like that: if (typeof module !== 'undefined' && module.exports) { I think that define from requirejs is coliding with define from puremvc. Any sugestion? thank you guys. Title: Re: puremvc with requirejs and or nodejs. Post by: puremvc on June 22, 2012, 07:06:13 I don't personally know about those frameworks, but I can say that puremvc.define should not collide with anyone else's define method since it is namespaced as puremvc.define() rather than just define().
Title: Re: puremvc with requirejs and or nodejs. Post by: drr00t on June 22, 2012, 11:20:04 Hi,
Thanks for answer, http://requirejs.org/ (http://requirejs.org/) is just a loader, i like to user for load external templates html and use with any javascript template engine like: doT, jquery template, etc... Normally requirejs need tha the library export their symbols, like i did on post before. I try do this but not work, because requirejs and puremvc both has a define method and i was making a change inside puremvc namespace, it generate the problem. 1 - But a try load diferente way, i just declare a requirejs module in file puremvc-wrap.js, like this:
2 - And to use new puremvc module in main.js file, i did this: require.config({ 3 - To use new puremvc module declaring my application facade in applicationFacade.js file, i did this:
5 - To use declared facade i back to main.js file, and i did this:
All work nicely, thank you for answer, sorry for the misundertanding. keep up with greate work. Title: Re: puremvc with requirejs and or nodejs. Post by: puremvc on June 23, 2012, 04:08:03 Thanks for posting your final approach, I'm sure this will be useful to others, so I think I'll make this topic sticky.
Cheers, -=Cliff> Title: Re: puremvc with requirejs and or nodejs. Post by: mikebritton on September 21, 2012, 10:26:04 Indeed, very helpful. Props all around.
Title: Re: puremvc with requirejs and or nodejs. Post by: jrmorrill on November 10, 2012, 07:10:09 Since this was created back in June, I think the syntax was using the 1.0 API. Here's some updates for how to add puremvc as a dependency if you are using the requireJS 2.0 API:
If you have the following directory structure: -+ |- index.html +- js/ | +- app/ | | |- controller | | |- model | | |- view | | |- ApplicationFacade.js | | | +- lib/ | | |- require.js | | |- puremvc.js | | | |- app.js Put the following script tag in your index.html index.html <script data-main="js/app.js" src="js/lib/require.js" type="text/javascript"></script> js/app.js
The js/app/ApplicationFacade.js file remains unchanged. Notice that the only real difference is that the shim is now built-in to requireJS. There is no need to wrap prototype as a module since we can setup support for it in the config. Just a simpler way to include other libraries that don't conform to the requireJS pattern for defining modules. Also, on a side note, these "shim" modules can also have dependencies that they require loaded with the deps: [], property. More info can be found here:http://requirejs.org/docs/api.html#config-shim Title: Re: puremvc with requirejs and or nodejs. Post by: puremvc on September 11, 2014, 08:18:59 Excellent! Thanks for the update.
|