can.Model is similar to a can.Map, but it includes built-in CRUD functionality.
Questions tagged [canjs-model]
44 questions
9
votes
1 answer
can-model cannot getting data from .json file
I am trying to implement MVC using AMD in canjs. For that I am using requirejs.
This is my domains.json file:
[
"1":{"uid": "1","urls": "domain1.abc.com"},
"2":{"uid": "2","urls": "domain2.abc.com"},
"3":{"uid": "3","urls":…

Dipesh Raichana
- 1,008
- 3
- 18
- 36
4
votes
1 answer
CanJS Model findAll returns list of duplicate items
I'm using can.Model to retrieve data by id:
Invoice = can.Model({
findAll: 'GET /invoices',
create : "POST /invoices",
update : "PUT /invoices/{id}",
destroy : "DELETE /invoices/{id}"
},{});
When navigating to /invoices, the…

Anton Gildebrand
- 3,641
- 12
- 50
- 86
3
votes
1 answer
How to get component reference inside of the model save callback functions?
I have a login component with a model that goes to the server and receives an error if the login was no correct.
Here is the idea of what I'm talking about:
var LoginModel = can.Model.extend({
create : "POST…

Flavio Garcia
- 1,491
- 1
- 14
- 20
3
votes
1 answer
CanJS object list automatic subclassing and reclassing
A remote, third-party JSONP server provides my CanJS script with a list of results like this one:
[
{ "class": "ABaseClass", "value": "1"},
{ "class": "ASubClass", "value": "2"},
{ "class": "ABaseClass", "value": "3"},
{ "class":…

Brian
- 7,394
- 3
- 25
- 46
3
votes
1 answer
More restfunctions on canjs model
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}',
…

user1988363
- 33
- 2
2
votes
1 answer
How to filter JSON data for autosuggestion using Ajax (without jQuery ui)
I am trying to create an auto-suggestion from scratch. I am using canjs controller to control the DOM elements (ul and li).
I want smart and short code to implement this. I have tried with filter but I want Ajax filter method to use for this…

Dipesh Raichana
- 1,008
- 3
- 18
- 36
2
votes
1 answer
The best way to show loader message during model.list loading
I created a simple MVC application with canjs for an users list, by using can.Model.List.
Since my request could take more than 5 second, I would add in the view a little preload message/image during the loading.
i.e. I would something like this…

Ciccio Ceras
- 23
- 2
2
votes
2 answers
Canjs - Extending can.Model with additional Methods
I'm not the first person to ask this... the answers basically say "Well you're doing REST wrong." Fair enough, but development is filled with tradeoffs and I often find myself not in a position to rewrite the API.
Moving on to the problem at hand,…

savinger
- 6,544
- 9
- 40
- 57
2
votes
1 answer
CanJS parseModels and data coercion
I think I may have an odd use case here. I've got a Code model with code, title, description attributes. Users are documenting work (healthcare), they enter the code, say 7, and 7 always means that something particular happened, say "The patient was…

savinger
- 6,544
- 9
- 40
- 57
2
votes
3 answers
How can I get the length of a deferred Model in CanJS?
I am getting a model deferred object with a structure like this:
How can I find out how many objects are present inside this object (in this case, three). If I use Object.keys(myObject).length, it includes the object observer and other data also…

Ankur Aggarwal
- 2,993
- 5
- 30
- 56
2
votes
1 answer
Could not get any raw data while converting using .models canjs
With the new CanJS update, my Models stopped working and I dont know why.
This is what my code looks like:
Module = can.Model.extend({
findAll: 'GET ' + window.rootPath+'api/module'
}, {});
FormModule = can.Control.extend({},…

Glund
- 507
- 1
- 5
- 20
2
votes
3 answers
CanJS findOne by name
I am using CanJS for a web application. I want to know how to implement search. I have implemented findAll but i want to implement findOne based on the name and not id.
var Library = can.Model({
findAll: "GET /libraries",
findOne: …

Shraddha Shravagi
- 1,096
- 1
- 9
- 22
1
vote
0 answers
Adding an item to a todo list in canjs
While attempting to copy and improve upon the todo list in the front page of canjs.org I have run into a bit of a snag. The example doesn't show you how to add items to a todo list. So I added a "Add another" span that executes newTodo when…

chriscauley
- 19,015
- 9
- 33
- 33
1
vote
0 answers
How can I trigger validation onblur with CanJS?
I have a Can JS model with an init that runs this.validateNonBlank("title");. How can I trigger that validation to run onblur, when I tab out of the title field? Right now it only triggers when another element triggers the change…

Dan Dascalescu
- 143,271
- 52
- 317
- 404
1
vote
1 answer
How get extra information from json?
I use can.Component to dispay JSON on the page.
can.Component.extend({
tag: "some-app",
scope: {
items: new Items.List({}),
displayedItems: function () {
...
return items;
}
},
…

Ilya
- 99
- 2
- 12