82225

Loading entire modules at once using backbone.js (multiple views, models, collections)

Question:

I've been toying with the idea of rebuilding a very antiquated in-house CMS using backbone.js so that I build more of an app than a website. So far I'm comfortable with backbone and I've added in require.js to break the application into modules but there's one small thing that's bothering me.

My impression of backbone is that it would be possible to deliver the application to the user in a single initial payload but since adding require.js all models, collections, views, and templates are fetched individually on an ad-hoc basis.

Is it possible to break my application into modular payloads? For instance if the user enters the news section of the CMS they are delivered all the views, models etc. required for that module? The only solution I can think of is wrapping all the pieces of a module in a single define function call but this seems to break the paradigm of uncoupling the pieces of the application as a whole.

Any suggestions?

Answer1:

Short answer:

try using requirejs modules

Long answer:

Check this out

https://github.com/ravihamsa/base-example/

I made an boiler-plate using requirejs, I call every module as an app, you can compile one JS file per module, and coupled with coupled with

https://github.com/ravihamsa/baseapp/

you can load each module on demand. But you got to follow the url pattern I do follow. like

http://yourapp.com/#appId/pageId/param1=value1;param2=value2

Whole app architecture is work in progress but you get enough insights

Answer2:

I think I've figured this out for myself. It looks like it's possible to use r.js (<a href="http://requirejs.org/docs/download.html#rjs" rel="nofollow">http://requirejs.org/docs/download.html#rjs</a>) to compile modules into a single script which is exactly what I need.

Recommend

  • Redux higher order components same as container components
  • React Functional Components with hooks vs Class Components
  • Can a team admin create a distribution provisioning profile? Or just the team agent?
  • SugarORM query from multiple tables?
  • How to compare multiple column with multiple field array in Select query?
  • Creating a table in “MSWord” document out of a text in a .txt file
  • Fetching Data From A Specific div id Using PHP [duplicate]
  • MSVC10 /MP builds not multicore across folders in a project
  • How to check whether the file exist in HDFS location, using oozie?
  • Use a foreach loop instead of while with myslqli_fetch_array()
  • Set UITableView BackgroundColor Universally with UIAppearance
  • Creating a Messenger service
  • JS Switch case not working correctly always default is executed
  • javascript XSLT nodes, selecting the first of a group (merge-like)
  • OpenXML how to get cell in range
  • How do I calculate a grouped z score in R using dplyr?
  • Passing Props from State to Child
  • wpf: update multiple controls via dispatcher
  • How to record a JNLP/ Java Web Start application with JMeter
  • 2-table interaction: insert, get result, insert
  • Multiple versions of iTunesArtwork in one project?
  • How to make nicEditor snaplet? (Several questions)
  • PWA with multiple pages
  • Mocha throws unexpected token error for ES6 object spread operator
  • Django model for a Postgres view
  • didUpdatePushCredentials not get called
  • Bash if statement with multiple conditions
  • Combining two different ActiveRecord collections into one
  • How do I include a SWC in an AS2 Flash project?
  • How to add a focus style to an editable ComboBox in WPF
  • Copy to all folders batch file?
  • How do I superscript characters in a UIButton?
  • Sencha Touch 2.0 Controller refs attribute not working?
  • Typescript - Unable to get 'import' statement to function
  • Sails.js/waterline: Executing waterline queries in toJSON function of a model?
  • Is my CUDA kernel really runs on device or is being mistekenly executed by host in emulation?
  • Unanticipated behavior
  • Traverse Array and Display in markup
  • KeystoneJS: Relationships in Admin UI not updating
  • NSLayoutConstraint that would pin a view to the bottom edge of a superview