English 中文(简体)
以 mvc 模式计时
原标题:sencha templating in mvc pattern

下面的代码为主视图, 即主视图 js, 在那里我已拨打Intro.js, 即另一种视图。 现在我无法在模板上提供数据 。 我是新来的 sencha, 我认为我在宣言上搞砸了一些事情 。

Ext.define("casta.view.Main", {
    extend:  Ext.tab.Panel ,
    apitoken: NULL ,
    requires: [
         Ext.TitleBar ,
         Ext.Video ,
         casta.view.Intro 

    ],
    config: {
        tabBarPosition:  top ,

        items: [


                { title: Intro ,
                   xclass:  casta.view.Intro  ,
                   iconCls: user 
                 }

                 ]
    }
});

Itro.js 和下面一样。我想在宣布变数时, 我搞砸了一些事情。 它显示空白屏幕 。

Ext.define( casta.view.Intro , {
extend:  Ext.tab.Panel ,
//alias:  widget.currentDate , //this makes it xtype  currentDate 
//store:  CurrentDateStore ,


initComponent: function(){
    planetEarth = { name: "Earth", mass: 1.00 };

    tpl = new Ext.Template([ <tpl for"."> ,  <p> {name} </p> ,  </tpl> ].join(  ));
    tpl.compile();
    //this.callParent(arguments);

},
html:tpl.apply(planetEarth)
});

下面是控制台日志

tpl is not defined

[在此错误上断开]

html:tpl.apply(planetEarth)
最佳回答

在 html var 设置之后的某个时候, InitComponent 将会被调用。 相反, 您的 tpl 定义会是这样 :

Ext.define( casta.view.Intro , {
    extend:  Ext.tab.Panel ,
    tpl:  <p> {name} </p> ,
    initComponent: function(){
        //Be sure to use the var keyword for planet earth, otherwise its declared as a global variable
        var planetEarth = { name: "Earth", mass: 1.00 };
        this.setHtml(this.getTpl().apply(planetEarth));
    }
});

这将工作, 遵循您的模式, 但你可能想要定义该组件, 更像 :

Ext.define( casta.view.Intro , {
    extend:  Ext.Container ,
    tpl:  <p> {name} </p> 
});

然后把它当做:

Ext.define("casta.view.Main", {
    extend :  Ext.tab.Panel ,
    apitoken :  NULL ,
    requires : [ Ext.TitleBar ,  Ext.Video ,  casta.view.Intro ],
    config : {
        tabBarPosition :  top ,
        items : [{
            xclass :  casta.view.Intro ,
            title :  Intro ,
            iconCls :  user ,
            data: {name: "Earth", mass: 1.00 }
            }]
    }
});
问题回答

暂无回答




相关问题
Check session from a view in CodeIgniter

What is the best way to check session from a view in CodeIgniter, it shows no way in their user guide, otherwise I will have to make two views on everything, which is kinda weird...still a newbie to ...

How to create a submit button template in Oracle APEX?

I m trying to create a template for a button in Oracle APEX but I don t seem to have access to the appropriate substitution strings to make it work. For non-templated buttons APEX seems to insert a ...

list of controls with templates in silverlight

Does anyone know where to find a list of controls that you can set the template on in Silverlight? I ve wasted several hours now trying to create control templates only to find that the control doesn ...

Template Classes in C++ ... a required skill set?

I m new to C++ and am wondering how much time I should invest in learning how to implement template classes. Are they widely used in industry, or is this something I should move through quickly?

Load ruby on rails template from database

I wonder if there is a way for me to store ruby on rails view files into database store and have that fetched directly from there. The reason is I want to create a CMS with all the user data stored in ...

Templated HTML Editor

I m looking for a HTML editor that kinda supports templated editing or live snippets or something like that. Background: I m working on a website for a friend. As there are no specifications what the ...

Dreamweaver changing path to site s reference instead of local

I have noticed recently, when I apply a template to a new HTML website, all the relative paths are pointed to my local files, example: file:///C|/webstuff/files but I cannot set them to relative paths ...

WPF ListView : Header styling

I want to have a ListView with columns and a particular style: The background for ALL column headers should be transparent except when the mouse is over in one of them. When this happends, the ...

热门标签