2014-10-07 34 views
0

我試圖調用從控制器中寫入的AJAX調用的視圖,也發送存儲在模型中的數據。ExtJs控制器使用數據調用視圖

這是呼叫:

var dummyAttivita = Ext.create('appTrial.model.Attivita', { 
    id: 1, 
    nomeAttivita : 'il Chiosco', 
    codiceAttivita: 'ago123' 
}); 
. 
. 
. 

doLogin: function() { 
    // called whenever the Login button is tapped 
    var codAttivita = Ext.getCmp('codAttivita').getValue(); 
    if(codAttivita != null || codAttivita !== undefined) { 
     if (codAttivita.length > 0) { 
      if (codAttivita === dummyAttivita.get('codiceAttivita')) { 
       Ext.Msg.alert('', 'entro', Ext.emptyFn); 
       var attivitaAssociata = Ext.encode(dummyAttivita.getFields); 
       Ext.Ajax.request({ 
        url : 'app/view/Postazione.js/', 
        method:'POST', 
        params,: {attivitaAssociata : dummyAttivita.getFields} 
        scope : this, 

        success : function(response, opts){ 
         //What should I put here??? 
        }, 
        //method to call when the request is a failure 
        failure : function(response, opts){ 
         Ext.Msg.alert('', 'Nothing', Ext.emptyFn); 
        } 
       }); 

      } else { 
       Ext.Msg.alert('', 'Il codice inserito non è associato ad alcuna attivita', Ext.emptyFn); 
      } 
     } else { 
      Ext.Msg.alert('', 'Inserisci il codice di una attivita', Ext.emptyFn); 
     } 
    } 
}, 

什麼我不理解是如何加載的URL參數中指定的新視角,也將存儲在PARAMS數據。 有沒有人有任何想法?

在此先感謝

+0

那是什麼視圖(表格面板,標籤面板或容器),它包含什麼? – RE350 2014-10-07 15:37:15

+0

這是一個簡單的容器,只是HTML文本的一刻;是否必須使用調用和調用視圖來更新帖子? – Ago 2014-10-07 15:42:26

回答

0

這應該做的伎倆

success : function(response){ 
    var returnJson = JSON.parse(response.responseText); 

    // either work with a store or save the data somewhere else 
    Ext.getStore('MyStore').add(returnJson); 
    // or you use your model (if data.is the base path inside the Json 
    dummyAttivita.set(returnJson.data); 

    // Here you add a route (should be inside the view controller 
    MyApp.app.redirectTo('newView'); 

    // alternative to Ext.getStore() is to use a tpl for the view 
    newView.setData(returnJson); 
}, 
+0

該行:「var returnJson = JSON.parse(response.responseText);給我錯誤:」未捕獲的SyntaxError:意外的令牌E – Ago 2014-10-07 16:20:25

+0

您的響應如何。你可以寫入你的文章? – Dinkheller 2014-10-08 10:06:26

+0

它包含定義到ajax調用的url屬性中的模型: 「response.responseText:」Ext.define('appTrial.model.Attivita'..「 – Ago 2014-10-14 10:22:32

0

然後,你可以寫你的成功之類的函數如下。

success : function(response, opts){ 
     Ext.getCmp('container_id').setHtml(Ext.decode(response.responseText)); 
    }, 
+0

不工作,但可能我沒有正確解釋它:我有一個視圖Login.js,它帶有一個名爲loginContainer的容器。上面的Ajax調用位於由Login.js調用的控制器內部。現在,在AJAX調用的onSuccess上,我將調用Postazione.js,它定義在postazioneContainer製作的ajax調用的url上,位於Login視圖的位置。 – Ago 2014-10-07 16:04:20

相關問題