简体   繁体   中英

'book' textfield does not trigger event in sencha

I have this code Ext.get('book').setValue('1');

Note: Loads the page and book value is set to 1. Not after page load and book value change to 1.

It sets the book to value 1. But it does not trigger a change event. Is there a way to trigger the change event after page loads?

Edit: In html script,

<script..>
    $(document).ready(function () { 
        $("book").on("blur", function() {
           //calls other function
        }); // not called as blur is not invoked 
    }); 
</script>

<input id="book" type="book" value="" /><br />

In extjs,

var panel = Ext.create('Ext.grid.Panel', {    
id: 'panel',
columns: [
    var bookid = "new book";
      Ext.Ajax.request({
        params: { bookid: bookid},
        function: function (response) {
           Ext.get('book').setValue(bookid);
           // after setValue, book will receive a change event(e.g .blur in html) and changes other functions 
        }
      });
]
});

Your ajax request seems to be malformed, the function: function statement would be the place where you put normally success: function like in the following statement:

Ext.Ajax.request({
    url: 'insert-your-http-endpoint-here',
    params: {
        bookid: bookid
    },
    success: function(response){
        debugger; // -> setting this statement will show that you enter the success statement
        Ext.get('book').setValue(bookid);
    },
    failure: function(response, opts) {
        // something went wrong with your request
        console.log('server-side failure with status code ' + response.status);
    }
});

more info about how to use ExtJS or the specific function, you could find in the documentation (check if you have the correct version, ofcourse) which can be found here

From the above code, you don't need the debugger statement, but it could help if you want to check if you actually get into this code block or not, and what happens when you try to set the value.

Also, don't forget to check your console output when something is not working, maybe there was a problem that would be clearly indicated in the console log

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM