Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ember.js deserialize implementation

I am experimenting with the newest Ember.js api, but I have run into a slight problem. Things look and work ok, except for the route deserialize method. To perfectly understand my problem, go to my blog http://eduardmoldovan.com/, click a post, it will load. Then refresh the page. All the content would disappear. What am I doing wrong here? Obviously something is badly implemented, but I cannot find the problem.

Here is the rote that handles this all.

Ngin.ArticleRoute = Ember.Route.extend({
    serialize: function(model) {
        "use strict";
        if (model) {
            return {
                channel: model.get("channel"),
                url: model.get("url") + "/"
            };  
        }

    },
    setupController: function(controller, model) {
        "use strict";
        controller.set("channels", Ngin.Channel.find());
        controller.set("comments", Ngin.Comment.find({
                filter: "comments-by-url",
                url: model.get("url")
            })
        );
        controller.set("content", model);
    },
    model: function(parameters) {
        "use strict";
        var article = Ngin.Article.find({
                filter: "by-url",
                url: parameters.url
            });
        return article;
    },
    renderTemplate: function() {
        "use strict";
        this.render("header", {
            outlet: "header"
        });
        this.render("article", {
            outlet: "content"
        });
        this.render("footer", {
            outlet: "footer"
        });
        $("html, body").animate({scrollTop: 0}, "fast");
    }
});
like image 849
Eduárd Moldován Avatar asked Dec 07 '25 03:12

Eduárd Moldován


1 Answers

Deserialize is no longer part of the public API, instead you should use the model hook. Here's a link to the ember guides article.

like image 82
Han Avatar answered Dec 11 '25 07:12

Han



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!