Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SubView复用 #46

Open
xspider opened this issue Jul 23, 2013 · 0 comments
Open

SubView复用 #46

xspider opened this issue Jul 23, 2013 · 0 comments
Labels

Comments

@xspider
Copy link
Collaborator

xspider commented Jul 23, 2013

<<返回目录

在SPA类应用中,会常常使用一些相同的SubView,Chassis提供了内部的机制来完成SubView的复用。

SubView的复用不需要使用额外的代码或则特殊处理,只需要按照模块的异步加载要求即可:不要手动的产生新实例(TODO去掉这一要求,使得每次产生相同的实例)

(function($){

Chassis.PageView.sayhello = Chassis.PageView.extend({

    el: '#sayhello_page'

    ,init: function(options){
        var me = this,opt;

        opt = $.extend({}, options);

        me.prepend('say_header',opt);
        me.setup('sayhello_content',opt);

        /* 这样写就不能异步加载
        me.setup(new rocket.subview.sayhello_header(
            $.extend({}, options)
            ,me
        ));

        me.setup(new rocket.subview.sayhello_content(
            $.extend({}, options)
            ,me
        ));
        */
    }

});

})(Zepto);

<<返回目录

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant