inherit
203080
0
Mar 17, 2014 14:50:56 GMT -8
baratheon
43
December 2013
baratheon
|
Post by baratheon on Mar 1, 2014 10:58:09 GMT -8
Hi.
In my plugin UI, I have an "items" autoform set up, with 5 rows/entries. I'm trying to grab their values in JS, but I continue to receive 'undefined' (and yes, the autoform rows are filled out). I ran the foreach loop in html before, and successfully returned all the values:
{foreach $[autoform_name]}
$[autoform_name.autoform_variable]
{/foreach} But like I said, I need to have the values accessible in JS. I imagine it to be something like this (but it doesn't work):
$(pb.plugin.get('fog_store').settings.items).each(function(key, val){
alert(pb.plugin.get('fog_store').settings.items.items);
});
|
|
inherit
Official Code Helper
65613
0
1
Oct 22, 2024 1:56:19 GMT -8
Chris
"'Oops' is the sound we make when we improve"
9,018
December 2005
horace
RedBassett's Mini-Profile
|
Post by Chris on Mar 1, 2014 20:52:44 GMT -8
The autoform would be served up as an array of objects. In the function you've supplied with the jQuery each, the key param would actually be the array index and val param would be the object itself. If each object has an "items" property then you would access it as val.items or val["items"]
Another way to put it would be you could access it directly sans jQuery with: pb.plugin.get('fog_store').settings.items[0].items pb.plugin.get('fog_store').settings.items[1].items pb.plugin.get('fog_store').settings.items[2].items pb.plugin.get('fog_store').settings.items[3].items pb.plugin.get('fog_store').settings.items[4].items
Five rows in an autoform would mean 5 objects in the array...
|
|
inherit
203080
0
Mar 17, 2014 14:50:56 GMT -8
baratheon
43
December 2013
baratheon
|
Post by baratheon on Mar 2, 2014 20:07:02 GMT -8
Works great! Thank you
|
|