1

我正在工作 extjs。我想通过 json 发送文本字段数据。所以我把代码写成了——

Ext.define('Balaee.controller.kp.WordController',{
    extend: 'Ext.app.Controller',
    stores: ['kp.WordStore'],
    models: ['kp.WordModel'],
    views: ['kp.Word.Word'],
    refs:[
       {
            ref:'wordtext',
            selector:'textfield[name=wordtext]'
       },
       ],
    init: function() {
        console.log('Inside word controller');
        this.control(
                {
            'Word button[action=SearchAction]':
            {
                click:this.SearchWord
            },

        });//End of control
    },//End of init() function

    SearchWord:function(button)
    {
        var j = Ext.getCmp('wordtext').getValue();
        console.log("word is:"+j);


                            var wordObject = Ext.ModelManager.create(
                {

                    word:Ext.getCmp('wordtext').getValue(),
                },'Balaee.model.kp.WordModel');


        wordObject.save({    
            success: function(record, operation) 
            {
                console.log("registration successssssssssss  "+record);
            },//End of success function
            failure: function(record, operation) 
            {
                console.log("Inside failure functionnnnn");
            },//End of failure function
            callback: function(record, operation)
            {
                console.log("Inside callback functionnnnnn");   
                console.log(record);
            }//End of callback function
        });// End of
    },


});//End of Controller

但它总是在故障功能。那么我需要做哪些额外的改变。请有人可以帮我...

4

1 回答 1

0

试试这个来创建你的 WordModel 实例:

    var wordObject = Ext.create(
      'Balaee.model.kp.WordModel',
      { word : j }
    );

或者你可能需要在模型中配置代理

于 2013-03-06T16:53:20.920 回答