canjs

How do I pass a can.compute into a can.Component?

我怕爱的太早我们不能终老 提交于 2019-12-14 02:55:57
问题 How can I pass computes into components, such that changing the value in selected in one component will affect a value in a different component. Example http://jsbin.com/feleko/1/edit?html,js,console,output I'm trying to set it up so that selecting a value in the first select changes the options available in the second. I think listening for dom change events should be straightforward, but I don't seem to be getting a compute I can update, or have access to the parent scope in order to use an

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

How do I Implement router in CanJS

戏子无情 提交于 2019-12-11 12:42:20
问题 I am taking help of the https://github.com/thinkadoo/Projects application. I have built a similar app with the help of this one. My application is using d3 charts instead of the one this uses. My app initializes the routers as var patientStatus = new PatientStatus('#application', {'credentials':Credentials,'secret':Secret}); Now if i want to implement Router then what changes should be done? Here is my JSFiddle with both implementations. The first one is working. But the later part where in I

CanJS Observable and dots in keys

人走茶凉 提交于 2019-12-11 12:27:31
问题 My problem is while using canJS Observable I can't use dots in object keys, because can think that some nesting available here. So let's say if I create new observable: var obs = new can.Observe( { "div.test-class": { "color": "#000000;" } } ); can fails with message can.Observe: Object does not exist And I can't create observable using just var obs = new can.Observe( { ".test-class": { "color": "#000000;" } } ); because now can fails with the following error: TypeError: current._set is not a

How can can.js add a record to a Rails server?

一曲冷凌霜 提交于 2019-12-08 08:32:20
问题 I am using Can.js to add a record to a Ruby on Rails server: var Todo = can.Model({ findAll : 'GET /todos', findOne : 'GET /todos/{id}', create : 'POST /todos', update : 'PUT /todos/{id}', destroy : 'DELETE /todos/{id}' }, {}); Todo.prototype.description = function() { return this.name + " and " + this.complete; }; Todo.findAll({}, function(todos) { todos.each(function(todo) { console.log(todo.name, todo.complete); console.log(todo.description()); }); }); var todo = new Todo({name: "mow lawn"

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,

How can can.js add a record to a Rails server?

别来无恙 提交于 2019-12-07 02:30:29
I am using Can.js to add a record to a Ruby on Rails server: var Todo = can.Model({ findAll : 'GET /todos', findOne : 'GET /todos/{id}', create : 'POST /todos', update : 'PUT /todos/{id}', destroy : 'DELETE /todos/{id}' }, {}); Todo.prototype.description = function() { return this.name + " and " + this.complete; }; Todo.findAll({}, function(todos) { todos.each(function(todo) { console.log(todo.name, todo.complete); console.log(todo.description()); }); }); var todo = new Todo({name: "mow lawn"}); todo.save(); the findAll() actually can get all the records, but the save() will insert a blank

Accessing variable from different files(module) using requirejs

大城市里の小女人 提交于 2019-12-06 15:00:17
问题 I am trying to make MVC structure of application in canjs. For that I am using requireJS to separate the code in different file. I have searched in google and i am following this tutorial but in that tutorail I dont find to access module variables in different modules. therefore I am following this method to do so. But I cannot achieve that. This is my code: requirejsconfig.js file : requirejs.config({ paths :{ enforceDefine: true, waitSeconds : 0, jquery : "https://ajax.googleapis.com/ajax

Accessing variable from different files(module) using requirejs

核能气质少年 提交于 2019-12-04 20:57:37
I am trying to make MVC structure of application in canjs. For that I am using requireJS to separate the code in different file. I have searched in google and i am following this tutorial but in that tutorail I dont find to access module variables in different modules. therefore I am following this method to do so. But I cannot achieve that. This is my code: requirejsconfig.js file : requirejs.config({ paths :{ enforceDefine: true, waitSeconds : 0, jquery : "https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min", main : "view/main", player : "view/player", PlayerModel : "/models