| Page 1 of 1 | [ 3 posts ] |
|
Hi,
i have the following code: Code: var dataSource = new Y.DataSource.IO({ source: "http://localhost" }); Y.on('click', login, '#btn1', this, true); var cfg = { method: 'GET', form: { id: 'myform', useDisabled: false } }; function login() { Y.io('insertreq.php', cfg); Y.on('io:success', onSuccess, this); Y.on('io:failure', onFailure, this); }; function onSuccess(id,response,args) { document.getElementById('myformmsg').innerHTML = response.responseText; document.forms['myform'].reset(); dataTable.datasource.load({ request: "/getdata.php" }); }; function onFailure(id,response,args) { document.getElementById('myformmsg').innerHTML = "Error, retry..."; document.forms['myform'].reset(); }; I am sending a form to "insertreq.php", updating a table. The answer is displaid in a html field "myformmsg". After the form is sent, i am updating the datasource for a YUI3 datatable. My problem: after clicking on the submit button, it seems that the "io:success" event keeps firing, every time i reload the datasource because both use the IO functionality. Could someone help me? Thanks a lot for your time! Regards, Kai |
Alberto SantiniYUI Contributor
|
Hello Kai.
You are using global events. http://developer.yahoo.com/yui/3/io/#configuration You should use transaction events, adding the handlers to your configuration object. For instance, Code: var cfg = { method: 'GET', form: { id: 'myform', useDisabled: false }, on: { success: onSuccess, failure: onFailure } }; Don't forget to comment out Y.on lines. Hope that helps, Alberto |
|
Thanks a lot! It works perfectly.
|
| Page 1 of 1 | [ 3 posts ] |
| You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum |
© 2006-2013 Yahoo! Inc. All rights reserved.
All code on this site is licensed under the BSD License unless stated otherwise.
About This Site · Security Contact Info
Powered by phpBB® Forum Software © phpBB Group