canjs-model

CanJS how to refresh a model

别说谁变了你拦得住时间么 提交于 2020-02-05 05:17:46
问题 I have a model which represents a list of jobs which are run on the server I want to poll the server for updates on a timer to show changes to the state of the jobs. How do I do this? My Control looks like this var control = Control({ defaults: { view: 'app/views/job-index.ejs' } }, { init: function () { this.element .empty() .append(can.view(this.options.view, this.options)); var options = this.options; window.setInterval(function() { options.result.refresh(); }, 1000); }, }); my model, so

CanJS how to refresh a model

寵の児 提交于 2020-02-05 05:17:07
问题 I have a model which represents a list of jobs which are run on the server I want to poll the server for updates on a timer to show changes to the state of the jobs. How do I do this? My Control looks like this var control = Control({ defaults: { view: 'app/views/job-index.ejs' } }, { init: function () { this.element .empty() .append(can.view(this.options.view, this.options)); var options = this.options; window.setInterval(function() { options.result.refresh(); }, 1000); }, }); my model, so

How to use Defer in canjs

偶尔善良 提交于 2020-01-06 15:18:39
问题 Featoff = can.Model.extend("featoff",{ findAll: { url: '/api.php/specialoffers?', type: 'GET', data: { max : 10 , pid : 977 , sid : 5934 } } }, {}); Feat = can.Control({ init: function() { var that = this; can.view('images/js/mn/temps/featured.ejs', featoff.findAll({}).then(function(d) { return { offerdata : d, secTitle : that.element.data('title') }; })).done(function(frag) { that.element.html(frag); }) }}); I am calling this using new Feat(); this is working now. So now I wanna reuse the

CanJs Model Service Method Implementations

丶灬走出姿态 提交于 2019-12-11 20:30:14
问题 I am having trouble understanding how to correctly implement the can.Model service methods. I currently have this var Foo = can.Model({ findAll: "GET /service/Editor.svc/foo", findOne: "GET /service/Editor.svc/foo/{id}", create: 'POST /service/Editor.svc/foo"', update: 'PUT /service/Editor.svc/foo"{id}', destroy: 'DELETE /service/Editor.svc/foo"{id}' },{}); I have looked at http://canjs.com/guides/Models.html and http://canjs.com/guides/Tutorial.html and CanJS Model findAll returns list of

CanJS add custom MODEL method

梦想与她 提交于 2019-12-08 08:32:15
问题 I want to add another function to get result from a CanJs Model i Have something like this: VideomakerModel = can.Model({ id:'ID', findAll: 'GET /videomakers/', findNear: function( params ){ return $.post("/get_near_videomakers/", {address:params.address}, undefined ,"json") } },{}); VideomakerModel.findNear({address : "Milan"}, function(videomakers) { var myList = new VideomakerControl($('#accordionVm'), { videomakers : videomakers, view: 'videomakersList' }); }); If I name the method

More restfunctions on canjs model

≡放荡痞女 提交于 2019-12-07 15:22:33
问题 Is there a way to add more rest bindings on model then just the four CRUD functions? var Customer = can.Model({ findAll: 'GET /customer', findOne: 'GET /customer/{id}', create: 'POST /customer', update: 'PUT /customer/{id}', destroy: 'DELETE /customer/{id}' //maybeAnOtherMethod: 'PUT /customer/{id}/activate' }, { }); 回答1: The idea behind REST is that you have resources and actions on these resources. The resource itself is described by a URL, the action is described by an http verb. Hence,