-
1. How to get data attributes in JS
ilya_shaikovsky Mar 10, 2011 8:09 AM (in response to v.bannur)use event.data
-
2. How to get data attributes in JS
v.bannur Mar 10, 2011 8:34 AM (in response to ilya_shaikovsky)Hi Ilya,
I have used event.data as below
<a4j:jsFunction name="loadPoints" data="#{gmBean.point}" oncomplete="createPoints(event.data)" />
function createPoints(data) {
alert(data.length);
for (var i = 0; data.length; i++) {
alert(data.lat);
var point = new GLatLng(data.lat, data.lng);
map.addOverlay(createMarkerWithIdentifier(point, data.desc));
}
}
Before i was geting size of the data list as value 4. Now that also i am not getting.
-
3. Re: How to get data attributes in JS
v.bannur Mar 10, 2011 9:32 AM (in response to ilya_shaikovsky)Hi Ilya,
Can you please help me in this. I stucked here.
Even though 'event.data' i am not getting attribute value.
I have attached the files.
-
GmapBean.java.zip 1.6 KB
-
googleMap.xhtml.zip 1.3 KB
-
-
4. Re: How to get data attributes in JS
ilya_shaikovsky Mar 11, 2011 4:00 AM (in response to v.bannur)Doh.. sorry. my mistake with event.data.. that's from 4.x
you was right using oncomplete="createPoints(data)"
need just one correction:
function createPoints(data) {
alert(data.length);
for (var i = 0; data.length; i++) {
var point = new GLatLng(data[i].lat, data[i].lng);
map.addOverlay(createMarkerWithIdentifier(point, data[i].desc));
}
}
note the data[i] usage as you passing the array to the handler.
Checked that it works for me fine.
-
5. Re: How to get data attributes in JS
v.bannur Mar 11, 2011 8:42 AM (in response to ilya_shaikovsky)Thank youuuuuuuuu very much.