javascript - How to run the event load on click? -


i'm trying deal transfer of data server.

my problem:

ext.onready(function(){  ext.define('person', {         extend: 'ext.data.model',         idproperty: 'personid',         fields: [{             name: 'personid',             type: 'int'         }, .......],         proxy: {                    type: 'ajax',                    api: {                             read: '1.php?id=90',                             create: 'create.php',                             update: 'upd.php',                             destroy: 'delete.php'                        }             }     });     person.load(1, {         //callback который будет выполнен когда запрос пройдет....            callback: function(p, operation){                 //p -это текущий объект alert(p.get('name'))   console.log(p.get('personid'));   //1  console.log(p.get('salary'))    //300   //document.getelementsbytagname('p')[0].innerhtml='<input type="button" value="click" onclick="function(){p.load()}">' //uncaught referenceerror: p not defined ? //uncaught syntaxerror: unexpected token (               }           });  person=new person; 

the above code works. how run event load() on button click? hope can me out thanks.

you mean button clicked -> load person

html

<div id="btn">button</div> 

javascript

ext.define('person', {     extend: 'ext.data.model',     fields: ['id', 'name'],     proxy: {         type: 'ajax',         api: {             read: '/someurl'         },         reader: {             type: 'json',             root: 'data',             successproperty: 'success',             totalproperty: 'total'         }     } });  ext.onready(function(){     document.getelementbyid('btn').addeventlistener('click', function(){         person.load(1);     }) }); 

Comments

Popular posts from this blog

Unable to remove the www from url on https using .htaccess -