2013-02-19 37 views
0

我正在使用extjs + Yii框架。我有看法原樣 QbQns.js-如何在extjs中調用按鈕單擊事件中的視圖

Ext.define('Balaee.view.qb.qbqns.Qbqns',  
     { 
    extend:'Ext.form.Panel', 
    requires:[ 
       'Balaee.view.qb.qbqns.QbqnsView' 
       ], 
       id:'qbqnsId', 
       alias:'widget.Qbqns', 
       title:'Qbqns', 
       height:500, 
       items:[ 
        { xtype:'QbqnsView',}, 
        ],//end of items square 
        buttons:[ 
           { xtype:'button', 
            fieldLabel:'Vote', 
            action:'voteAction', 
            name:'vote', 
            formBind:true, 
            text:'submit', } ] }); 

在此提交按鈕點擊,我想創建新的視圖原樣

Ext.define('Balaee.view.qb.qbqns.QbqnsReviewView', 
    { 
      extend:'Ext.view.View', 
      id:'qbqnsViewId', 
      alias:'widget.QbqnsReviewView', 
      //store:'kp.PollStore', 
      store:'qb.QbqnsStore', 
      config: 
      { 
       tpl:'<tpl for=".">'+ 
        '<div id="main">'+ 
        '</br>'+ 

        '<h1 id="q">Question :-</h1> {question}</br>'+ 

       /* '<tpl for="options">'+  // interrogate the kids property within the data 
         '<p>&nbsp&nbsp<input type="radio" name="{parent.questionId}" value="{option}">&nbsp{option}</p>'+ 
        '</tpl>'+*/ 

        '<tpl for="options">'+ 
         '<tpl if="parent.Correctoption==option">'+ 
         //'<tpl if="Correctoption==UsersOption">'+ 
         '<p style="color:Green"><input type="radio" name="{optionId}">{option}</p>'+ 

         '<tpl elseif="parent.UsersOption==option">'+ 
         '<p style="color:Red"><input type="radio" name="{optionId}">{option}</p>'+ 

         '<tpl else>'+ 
         '<p><input type="radio" name="{parent.questionId}" value="{option}">&nbsp{option}</p>'+ 

         '</tpl>'+ 
        '</tpl>'+ 



    '<p>---------------------------------------------------------</p>'+ 
        '</div>'+ 

        '<h1 id="q">Total marks are:-</h1>{Total}'+ 
        '<h1 id="q">Score you got is:-</h1>{Score}'+ 

        '</tpl>', 



       itemSelector:'div.main', 
      } 
    });// End of login class 

那麼如何調用從控制器上提交按鈕此上述觀點單擊。請給我建議...

+0

有人可以請指導我 – user2077845 2013-02-19 06:31:50

回答

0

在你的控制器:

init: function() { 
    this.control({ 
     'button[action=voteAction]': { 
      click: function(btn) { 
       Ext.create('Balaee.view.qb.qbqns.QbqnsReviewView', { 
        renderTo: Ext.getBody(); //<-- where you want render it 
       }); 
      } 
     } 
    }); 
} 

而且在你看來商店是一個字符串了。使用Ext.create()或Ext.getStore(storeId)。您可能需要閱讀guide

+0

thanx先生的答覆... Actully先生我曾嘗試,因爲你有建議。但它給我錯誤作爲QbqnsReviewview沒有發現錯誤。我還在控制器中聲明瞭所有視圖。 – user2077845 2013-02-19 06:50:46

+0

@ user2077845將您的QbqnsReviewView.js文件放在/ Balaee/view/qb/qbqns目錄中嗎? – Vlad 2013-02-19 06:55:15

+0

↑或者「你的...」(?) – Vlad 2013-02-19 06:56:38

相關問題