Friday 15 February 2013

javascript - Backbone update model -


In the spinal cord I have created the following models, compilations and views

var sensor = Backbone.Model.extend ({})

var sensor selection = backbone compilation. Extension ({Model: sensor})

Miscellaneous sensors = new sensor selection;

var SensorView = Backbone View. Extension ({})

var AppView I also have this PHP socket running:

var app = new app view

  var conn = new ab Session ('ws: localhost: 8080', function () {conn.subscribe ('temperature', function (subject, data) {console.log ('current temperature readings + data time); sensor .set ({temperature: data temperature} ); // attempt to change backbone model}}}, function () {console.warn ('offset webservice connection');}, {'SkipSubprotocolCheck': true});   

I am trying to change / update the model with reading the temperature coming from the socket, as you can see that I have tried with sensor.set and the following Also tried on written:

App.model.set

this.model.set < P> App.sensor.set

And in each different way it says that undefined or did not get some function about what is missing me? They are all one How can I update my Rebbone model with my Auto Socket Socket function? >

backbone.model. Extension ({}) returns a class, not for example. You should write instead:

 var sensor = backbone.model. Extension ({}); Var sensor = new sensor (); Sensor.one ('change: temperature', function (temperature) {console.log ('new temperature:' temperature);}); Var conn = new ab Session ('ws: localhost: 8080', function () {conn.subscribe ('temperature', function (subject, data) {console.log ('current temperature readings + data time); sensor .set ({temperature: data temperature} ); // attempt to change the backbone model}}}, function () {console.warn ('webcast connection off');}, {'SkipSubprotocolCheck': true});   

No comments:

Post a Comment