Quantcast
Channel: JavaScriptMVC Forum
Viewing all articles
Browse latest Browse all 3491

Re : Bind and events understanding

$
0
0
Yes. For example, code returns findOne and log:
  1. Recipe = can.Model.extend({
        destroy : "DELETE /collection/{id}",
        findOne : "GET /collection/{id}"
    },{});
  2. Recipe.findOne({id: 121}, function(recipe){
        console.log(recipe);
    });

Log:

  1. GET http://localhost/collection/121

    Server return:
  2. [{"id":121,"created":1416865621,"updated":1416862021,"visible":0,"name":"N 0.8726805504271906","sort":0,"color":0}]

    In console.log(recipe);
  3. a { 0=a, _data={...}, _cid=".map3", ...}


And my RESTful interface (PHP):

  1.     function get() {
            // a lot of code
           
            if($result)
                print json_encode($result, JSON_UNESCAPED_UNICODE);
            else
                return $this->f3->error(400);
        }
       
        function delete() {
            // a lot of code

            if($this->collection->delete($this->collection_id))
                return $this->f3->status(200);
            else
                return $this->f3->error(400);      
        }

Viewing all articles
Browse latest Browse all 3491

Trending Articles