edit - backbone.js beginner attempting to load data -


attempting post beginner question not making past "quality standards" filter. read through thread on error message. beginner questions basic? understandable might better put in error message. include code , english correct outside of code block. question has not been addressed, or @ least not returned various search patterns. there anyway appeal filter multiple rewrites have not cleared hurdle or solved my, admittedly beginner, problem? in last ditch attempt hack filter i'm pasting original question in bellow few english edits. edit - seems have worked leaving above paragraph in not jinx it.

trying load data backbone render function not firing. firebug shows arriving correct data string. have attempted assign "this" variable , fire function still no luck.

(function($) { var dobj = backbone.model.extend({     defaults: {         dstring: 'dstring again'     }, });  var mobs = backbone.collection.extend({     defaults: {         model: dobj     },     model: dobj,     url: 'scr/bbone.php' });  var mview = backbone.view.extend({     initialize: function() {         this.collection = new mobs();         //this.collection.bind("reset", this.render, this);         this.collection.on("sync", this.render, this);         //this.collection.bind("change", this.render, this);         this.collection.fetch();     },     render: function() {         alert("here : ");     } }); var newmob = new mview();  })(jquery); 

i have rewritten code mockjax mock response server, here is:

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script> <script src="http://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.4.4/underscore-min.js"></script> <script src="http://cdnjs.cloudflare.com/ajax/libs/backbone.js/1.0.0/backbone-min.js"></script> <script src="http://cdnjs.cloudflare.com/ajax/libs/jquery-mockjax/1.5.1/jquery.mockjax.min.js"></script>  <script>  var dobj = backbone.model.extend({ });  var mobs = backbone.collection.extend({      model: dobj,     url: '/movies' });  $.mockjax({    type: 'get',    url: '/movies',    contenttype: 'text/json',    status: 200,    response:  function() {        this.responsetext = json.stringify(new mobs([{ name: 'lincoln' }, { name: 'argo' }]));     } });  var mview = backbone.view.extend({     initialize: function() {         this.collection.on("sync", this.render, this);     },     render: function() {         alert("here : ");     } });  (function($) {    var newcol = new mobs();        newmob = new mview({ collection: newcol });     newcol.fetch({        success: function () { console.log('success'); },       error: function() { console.log('error'); }    });  })(jquery); 

i think there many issues code, issue asking has server response; should see alert above code. recommend read backbone.js documentation others.


Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -