This support forum belongs to the AlloyUI State Interaction Gallery Module.
AlloyUI State Interaction has a bug tracker here: http://issues.liferay.com/browse/AUI
| Page 1 of 1 | [ 3 posts ] |
|
I'm trying to create 2 simple functions to set and to get a value from an input field on a form. These functions should later be used from another form and vice versa.
Setting the value works ok like expected. Getting the value gives me an undefined value after returning the value. Any suggestions how to solve this or perhaps a clue to achieve the same functionality. Thanks in advance URL to the example: http://www.digirent.nl/psmyui/vb/getsetvalues.html Code: function set_value(id,val) { AUI('node').ready(function(A) { A.get('#'+id).set('value',val); }) } function get_value(id) { var value; AUI('node').ready(function(A) { value=A.get('#'+id).get('value'); alert('1 value:'+value); }); alert('2 value:'+value); } AUI('node').ready(function(A) { set_value('klant','Hendriks'); var retval=get_value('klant'); alert('3 retval:'+retval); }); |
Eduardo LundgrenYUI Contributor
|
Hi, you can use the .val() method as getter and .val('new value') as setter. See the documentation here on aui-node page: http://alloy.liferay.com/deploy/api/A.N ... method_val
var node = A.one('#input'); node.val('testing'); // setting the value alert( node.val() ); // output "testing" |
Nate CavanaughYUI Contributor
|
I also think the format of the AUI() code might cause some problems.
Try this instead: AUI().ready('aui-node', function(A){ A.one('#'+id).val(); }) But part of this might be the format, and the fact that inside of your function, you're doing an alert outside of the ready. AUI().ready(function(){}) is asynchronous, so your alert('2 value') might fire before the alert('1 value') because the "ready" event might not have happened yet, or it might be taking a longer time to pull down the package. This is one of the issues with returning data and asynchronous functions. Since .val() will act as a getter and setter, is it possible to use that inside of your app rather than the global get_value function? |
| 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