0

Textbox onKeyUp from code side ?

asked 2012-08-11 08:39:52 +0800

bricecol gravatar image bricecol
43 4

Hi everybody,

I'm looking for a way to add an onKeyUp event listener from code site (from a class which extends Textbox). I can add this event listener from ZUL with client namespace but in this case, I can't access to the ZK textbox after the treatments of onKeyUp...

Does someone have an idea ?
Thanks

delete flag offensive retag edit

2 Replies

Sort by ยป oldest newest

answered 2012-08-11 10:02:26 +0800

bricecol gravatar image bricecol
43 4

updated 2012-08-11 10:06:27 +0800

I reformulate and give you more details.

I would like to use Google autocomplete place JS lib.
So I have a textbox :

<textbox id="txbAddress"></textbox>

I need to access to the native input element in order to use Google AE Place lib, so I wrote this code :

	<script type='text/javascript'
		src='http://maps.googleapis.com/maps/api/js?libraries=places&sensor=true'>
<textbox id='txbAddress'>
				<attribute name='onFocus'>
			<![CDATA[
	Clients.evalJavaScript("var me = document.getElementById('"
			+ self.getUuid() + "');");
	if (self.getAttribute("ginit") == null) {
		Clients.evalJavaScript("var ac = new google.maps.places.Autocomplete(me);");
		Clients.evalJavaScript("google.maps.event.addListener(ac,'place_changed',function(){"
				+ "var place = ac.getPlace();"
				+ "var lat=place.geometry.location.lat();"
				+ "var lng=place.geometry.location.lng();"
				+ "var formatted_address=place.formatted_address;"
				+ "alert(formatted_address);" + "});");
		self.setAttribute("ginit", true);
	}
]]>
				</attribute>
			</textbox>

This code does an alert with the formatted address which is returned by Google lib, so it's working.

==> My problem now is to get the place value from Java code side. But I don't know how to access to the ZK component value from it's native JS var...

I try to do somethings like this :

$(me).attr('toto', 'i want to get this sentence');

And from Java code site I tried the getAttribute function and also I tried to get the component using UUID too and nothing is working (like the component is not refreshed by ZK because the attribute is created when I'm looking the source code)

link publish delete flag offensive edit

answered 2012-08-13 07:18:21 +0800

bricecol gravatar image bricecol
43 4

Please, I need help. Does someone know how to set for example an attribute of a ZK component from JS ?

link publish delete flag offensive edit
Your reply
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow

RSS

Stats

Asked: 2012-08-11 08:39:52 +0800

Seen: 211 times

Last updated: Aug 13 '12

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More