javascript - How to boot a multi-page app with Browserify and Gulp -


ok, i'm near finish line new php/js app built gulp , browserify. last part how "boot", mean how "first call".

let's have 3 js entry points

/js/articles.js /js/categories.js /js/comments.js 

each of them using js modules. have 3 html files, requiring js

/articles.html /categories.html /comments.html 

example /js/articles.js

var $ =                 require("jquery"); var common =            require("../common.js");  var viewmodel = {      readdata: function() {         /* read record api , render */     },      insert: function() {         /* open modal insert new record */     } }; 

what should perform sort of "boot": calling init function need, load server data, bind buttons , stuff viewmodel's methods

$(document).ready(function() {     common.init();     viewmodel.readdata();     $('#btn-add').click(viewmodel.insert); }); 

ok, put this?

a) in html file? can't cause don't have global js variabile access..

b) put articles.js? @ moment, gulp task bundle (articles.js, categories.js, comments.js, common libraries) single bundle.js. if put articles.js end bundle.js. articles-related boot stuff called in "categories" page either. , wrong.

c) should split articles.js 2 files, 1 containing viewmodel definition , other doing $(document).ready stuff?... again how access correct viewmodel?

which correct solution?

thank you


Comments

Popular posts from this blog

php - Permission denied. Laravel linux server -

google bigquery - Delta between query execution time and Java query call to finish -

python - Pandas two dataframes multiplication? -