[Seaside] Re: get value within a textinput with jQuery

Sabine Knöfel sabine.knoefel at gmail.com
Tue Jul 16 14:18:24 UTC 2013


Hi Johan,

because the value parameter of the field does only contain the letters
the user just entered and not the whole name of the adress which was
selected by the user. E.g. user typed in 'd' and selected 'Dallas,Tx'
from the list. Now, the value parameter of the field does only contain
the 'd' and not 'Dallas, Tx'.

The following code shows this as demo, you need only the 2 methods
below and setter/getter for startPlace.
There is a second textinput 'testTextField' that is also populated
with the adress selected.
So I see, ths js is working.
But within the  callback, the inspector shows me, that only the typed
letters will be saved and not the whole selected adress.

renderContentOn: html
	| mid fid |
	mid := 'widgetId'.
	fid := 'formId'.
	html
		html:
			('<script type="text/javascript">
	jQuery(function() \{
var input = document.getElementById(''widgetId'');
var autocomplete = new google.maps.places.Autocomplete(input);
google.maps.event.addListener(autocomplete, ''place_changed'', function() \{
var place = autocomplete.getPlace();
var adr = place.formatted_address;
jQuery(''#widgetId'').val(adr);
jQuery(''#testTextField'').val(adr);
});
});
</script>

<div>
<input id="testTextField" type="text" size="50"/>
</div>

 '

 format: {mid}).
	html textInput
		id: mid;
		size: 45;
		value: self startPlace;
		callback: [ :value |
			value inspect.
				
			self startPlace: value  ];
			
		onChange:
				(html scriptaculous updater
						id: mid;
						triggerForm: fid;
						callback: [ :r | r render: startPlace ]);
		onBlur: html jQuery ajax serializeThis


updateRoot: aHtmlRoot

super updateRoot: aHtmlRoot.
aHtmlRoot javascript url:
'https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js'.
aHtmlRoot javascript url:
'https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false&libraries=places'.



On Tue, Jul 16, 2013 at 4:01 PM, Johan Brichau-2 [via Smalltalk]
<ml-node+s1294792n4698947h52 at n4.nabble.com> wrote:
> Sabine,
>
> I'm a bit confused: why is the value parameter of the callback of the field
> not enough?
>
> Sent from my iPad
>
> On 16 Jul 2013, at 15:40, Sabine Knöfel <[hidden email]> wrote:
>
> Hi Johan,
>
> I want to get the value of the textinput within the callback of the
> textinput.
>
> Explanation:
> With Google Places autocompleter
> (http://webtrouble.blogspot.de/2013/01/google-address-autocomplete.html),
> the user selected a place which is displayed in the textInput.
> This works fine.
>
> Now, I want to save this place in my model.
>
> renderStartPlaceOn: html
>
> "this script sets the selected place in the field with the id 'mid'"
> html html: ('<script type="text/javascript">
>         jQuery(function() \{
> var input = document.getElementById(''{1}'');
> var autocomplete = new google.maps.places.Autocomplete(input);
> google.maps.event.addListener(autocomplete, ''place_changed'', function() \{
> var place = autocomplete.getPlace();
> var adr = place.formatted_address;
> jQuery(''#{1}'').val(adr);
> });
> });
> </script>' format: {mid}).
>
> "this is the text input with id 'mid' "
> html textInput
>         id: mid;
>         size: self defaultEntryFieldWidth;
>         value: self startPlace;
>         callback: [ :value | |theStartPlaceString|
> "**********This does not work, how can I get the value from the mid
> field which was set by the script above?********"
>                                 theStartPlaceString:= html jQuery ajax
>                                          callback: [:v | v inspect. ]
>                                         value: (html jQuery id:
> #searchTextField) value.
>                                 self startPlace: theStartPlaceString ];
>                                 onChange:
>                                                                 (html
> scriptaculous updater
>
> id: mid;
>
> triggerForm: fid;
>
> callback: [ :r |
>
> r render: self startPlace ]);
>                                 onBlur: html jQuery ajax serializeThis.
>
> Greetings
> Sabine
>
>
>
> On Tue, Jul 16, 2013 at 3:15 PM, Johan Brichau-2 [via Smalltalk]
> <[hidden email]> wrote:
>
>> Hi Sabine,
>>
>> I guess you want the value server-side?
>> You thus need to serialize that value:
>>
>> html jQuery ajax
>>     callback: [:v | ... ]
>>     value: (html jQuery id: #searchTextField) value
>>
>> Johan
>>
>> Sent from my iPad
>>
>> On 16 Jul 2013, at 14:01, Sabine Knöfel <[hidden email]> wrote:
>>
>>> Hi,
>>>
>>> I want to get the value which was entered into a textinput by doing
>>>
>>> (html jQuery id: #searchTextField) value.
>>>
>>> but I get
>>> a JQueryInstance
>>> (jQuery("#searchTextField").val())
>>>
>>> How can I get the value (String) of the text field?
>>>
>>> Greetings
>>> Sabine
>>>
>>>
>>>
>>>
>>>
>>> --
>>> View this message in context:
>>>
>>> http://forum.world.st/get-value-within-a-textinput-with-jQuery-tp4698913.html
>>> Sent from the Seaside General mailing list archive at Nabble.com.
>>> _______________________________________________
>>> seaside mailing list
>>> [hidden email]
>>> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>> _______________________________________________
>> seaside mailing list
>> [hidden email]
>> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>>
>>
>> ________________________________
>> If you reply to this email, your message will be added to the discussion
>> below:
>>
>> http://forum.world.st/get-value-within-a-textinput-with-jQuery-tp4698913p4698938.html
>> To unsubscribe from get value within a textinput with jQuery, click here.
>> NAML
>
> ________________________________
> View this message in context: Re: get value within a textinput with jQuery
>
> Sent from the Seaside General mailing list archive at Nabble.com.
>
> _______________________________________________
> seaside mailing list
> [hidden email]
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>
>
> _______________________________________________
> seaside mailing list
> [hidden email]
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>
>
> ________________________________
> If you reply to this email, your message will be added to the discussion
> below:
> http://forum.world.st/get-value-within-a-textinput-with-jQuery-tp4698913p4698947.html
> To unsubscribe from get value within a textinput with jQuery, click here.
> NAML




--
View this message in context: http://forum.world.st/get-value-within-a-textinput-with-jQuery-tp4698913p4698952.html
Sent from the Seaside General mailing list archive at Nabble.com.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/seaside/attachments/20130716/bc32a5ad/attachment.htm


More information about the seaside mailing list