Questions tagged [canjs-model]

can.Model is similar to a can.Map, but it includes built-in CRUD functionality.

44 questions
0
votes
1 answer

can.Model with can.view to populate DOM dynamically or once records are loaded

There is the following can.Model: var CaseModel = can.Model.extend({ findAll: function(args){ var def = $.Deferred(); args.sobject.retrieve(args.criteria, function(err, records) {//records should be populated into view …
Natallia
  • 157
  • 1
  • 9
0
votes
1 answer

canjs templating model which is not ready yet. Databinding

I've an issue in rendering the object which is not ready on the moment when the template is rendered. Thus it is rendering the empty view without databinding. What's the correct way to use deferred objects or some other method for ensuring the…
Heikki Mustonen
  • 301
  • 3
  • 15
0
votes
1 answer

How to refresh current view with new model object

I am building one simple task application in which I can add new status. Scenario is I have already build the status dashboard using predefined array of objects by calling can.Model findAll method. View is stored in 'dashboard.ejs'. As I create new…
Ankur Aggarwal
  • 2,993
  • 5
  • 30
  • 56
0
votes
1 answer

With CanJS, how to automatically remove a model instance from a Model.List when the instance gets destroyed?

I'm struggling to understand how calling destroy on a model instance is supposed to affect the Model.List it's attached to. The documentation states that: One advantage that can.Model.List has over a traditional can.List is that when you destroy…
Alex Marandon
  • 4,034
  • 2
  • 17
  • 21
0
votes
1 answer

How to use Defer in canjs

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 =…
0
votes
1 answer

can findAll be used to connect to an content api?

can findAll be used to connect to an content api and then get all the data and then can we use the findone to filter the data depending upon the id or the field
0
votes
1 answer

CanJs Model Service Method Implementations

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…
ford prefect
  • 7,096
  • 11
  • 56
  • 83
0
votes
1 answer

How to make can.Model send JSON data when update?

I have this code: var SotriesModel = can.Model.extend({ findAll: 'GET /api/stories/', create: function(story) { console.log(story) return $.ajax({ url: '/api/stories/', type: 'POST', …
nvcnvn
  • 4,991
  • 8
  • 49
  • 77
0
votes
2 answers

Option to specify base server url for can.Model?

Is there a way to specify the base url for can.Model? I see the server path being hard coded this way: Wine = can.Model({ findAll : 'GET //localhost/Cellar-CanJS-Bootstrapped/api/wines', findOne : 'GET…
Teo Choong Ping
  • 12,512
  • 18
  • 64
  • 91
0
votes
2 answers

CanJS storing a todo to a file

I am writing a SPA using CanJS which has a list and user can add the list. I want to store the newly added item permanently by writing it to a file. Can some one help me? '.btn_save click': function (ele, ev) { var self = this; var…
Shraddha Shravagi
  • 1,096
  • 1
  • 9
  • 22
0
votes
2 answers

Get Object from observable attr

I need some observable for my JSON. Data looks like this: { "event": [{ "id": 1, "name": "First", "param": { "a": 1, "b": [1, 2, 3] } }, { "id": 2, "name": "Second", "param": { "a": 1, "b":…
Vladislav
  • 371
  • 4
  • 12
0
votes
1 answer

Canjs model returns undefined after resolved

I cannot find a way to retrieve data from the server and convert them to model instance. I folloed the instructions here but it's still doesn't work. Here is my setup: url for the service: services/foo/barOne. The response is :…
Geekingfrog
  • 191
  • 1
  • 8
0
votes
1 answer

Dynamic properties for CanJS model?

I would like to add dynamic properties in my model that is not in the REST service results. These dynamic properties would shorten names, format dates, etc. For example, my CanJS model like this: var MyModel = can.Model({ findAll: 'GET…
Basem
  • 594
  • 1
  • 9
  • 25
-1
votes
1 answer

Canjs findall and findone?

So right now I am accessing the data using the findAll: 'GET api.php/stores-for-you?pid=977&sid=5938&max_fav=3&max_reco=3' which is a way to access the api for my application where pid is the page id and sid is the section id. So each page has…
1 2
3