从一个区域切换到另一个木偶,观点不正确呈现 [英] Switching from a region to another in Marionette, views are not rendered correctly

查看:130
本文介绍了从一个区域切换到另一个木偶,观点不正确呈现的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我与木偶工作,我有以下问题。

I'm working with Marionette and I have the following problem.

我已经创建了两个不同的区域布局。在初始化布局负荷在我的布局两个地区两种意见。说 ViewA ViewB 。在 ViewA 事件被触发。本次活动由布局消耗的切换和其他两个视图注入。说 ViewC ViewD
每当进行切换, ViewC ViewD 不具有相同的风格(也是CSS)是我申请他们。特别是,jQuery Mobile的样式不适用。有什么建议?

I've created a layout with two different regions. On initialize the layout loads two views in two regions of my layout. Say ViewA and ViewB. Within ViewA an event is triggered. The event is consumed by the layout to switch and other two views are injected. Say ViewC and ViewD. Whenever the switching is performed, ViewC and ViewD do not have the same style (also the css) that I applied to them. In particular, jQuery Mobile styles are not applied. Any advice?

下面一些code,其中的意见突出的重要组成部分。

Here some code where comments highlight the important parts.

onConfirm : function() {        
        this.leftView =  new ViewC();
        this.rightView = new ViewD();

        this.leftRegion.show(this.leftView);                                                                        
        this.rightRegion.show(this.rightView);

        // FIX calling trigger('create') seems fix the problem. Why? Is this correct?
        this.$el.trigger('create');
    },

initialize : function() {
        // listen for event triggered from ViewA
        // e.g. GloabalAggregator.vent.trigger("ga:confirm");
        // where "ga:confirm" is a simple string
        GloabalAggregator.vent.on("ga:confirm" , this.onConfirm, this);  

        this.leftView =  new ViewA(), // creating here a new ViewC the style is applied correctly
        this.rightView = new ViewB(); // creating here a new ViewD the style is applied correctly
    },

onRender : function () {
        this.leftRegion.show(this.leftView);                                                                        
        this.rightRegion.show(this.rightView);
    }

修改

调用触发('创造')似乎解决这​​个问题。为什么?这是正确的?

Calling trigger('create') seems fix the problem. Why? Is this correct?

推荐答案

当你添加新的HTML页面(添加新的视图,一些其他观点交换看法,等等。),你必须让jQuery Mobile的了解这个。

When you add new html to page (add new rendered view, swap view for some other view, etc..), you have to let jQuery mobile know about this.

创建事件用于加强与jQuery Mobile的小部件原始的HTML。更多信息可以在这里找到: http://jquerymobile.com/demos/ 1.0 /文档/页/页scripting.html
寻找加强新的标记一节。

"create" event is used to enhance "raw" html with jQuery Mobile widgets. More info can be found here: http://jquerymobile.com/demos/1.0/docs/pages/page-scripting.html Look for "Enhancing new markup" section.

这篇关于从一个区域切换到另一个木偶,观点不正确呈现的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆