jQuery value.

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

jQuery value.

Malte Grunwald
Hey everybody,

i try to get the value of a textInput with jQuery by using  it this way:

(html textInput)
                    id: id;
                    onBlur: html jQuery ajax serializeForm;
                    onBlur: ((html jQuery id: 'imageDiv') load html: [:r | self renderImageOn: r]);
                    onChange: (html jQuery new load html: [self formatValue: (html jQuery id: id)value]);
                    callback: [...];
                    value: (anObject perform: aValue)];


but I do not get the real value in the formatValue: method. All I get is: JQueryInstance ($("#id4").val()).
Have anybody an idea what I am doing wrong?

Thank you and kind regards

Malte

_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: jQuery value.

janus
Hey,
try this:
html textInput
                            onChange:
                                (html jQuery ajax callback: [ :inputValue |Transcript show: inputValue] value: html jQuery this value)

Kind regards,

Micha

Am 05.07.2012 15:28, schrieb Malte Grunwald:
Hey everybody,

i try to get the value of a textInput with jQuery by using  it this way:

(html textInput)
                    id: id;
                    onBlur: html jQuery ajax serializeForm;
                    onBlur: ((html jQuery id: 'imageDiv') load html: [:r | self renderImageOn: r]);
                    onChange: (html jQuery new load html: [self formatValue: (html jQuery id: id)value]);
                    callback: [...];
                    value: (anObject perform: aValue)];


but I do not get the real value in the formatValue: method. All I get is: JQueryInstance ($("#id4").val()).
Have anybody an idea what I am doing wrong?

Thank you and kind regards

Malte


_______________________________________________
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
Reply | Threaded
Open this post in threaded view
|

Re: jQuery value.

Malte Grunwald
Thank you for the quick reply, but if I use it this way, I get
JQAjax ($.ajax({"url":"/WebFox","data":["_s=hXLKkyBPny61oAIG","....


Am 05.07.2012 15:41, schrieb Michael Backmann:
> html jQuery ajax callback: [ :inputValue |Transcript show: inputValue]
> value: html jQuery this value


_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

RE: jQuery value.

Robert Sirois
#callback:value: is the method you want. It may be easier to take out some of your other code and just make sure you're getting the text input value, and then add in the other #onBlur:, etc. code.

RS

> Date: Thu, 5 Jul 2012 15:56:09 +0200

> From: [hidden email]
> To: [hidden email]
> Subject: Re: [Seaside] jQuery value.
>
> Thank you for the quick reply, but if I use it this way, I get
> JQAjax ($.ajax({"url":"/WebFox","data":["_s=hXLKkyBPny61oAIG","....
>
>
> Am 05.07.2012 15:41, schrieb Michael Backmann:
> > html jQuery ajax callback: [ :inputValue |Transcript show: inputValue]
> > value: html jQuery this value
>
>
> _______________________________________________
> 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
Reply | Threaded
Open this post in threaded view
|

Re: jQuery value.

Johan Brichau-2
In reply to this post by Malte Grunwald
Malte,

I think you want this (explanation below):

|theValue|
(html textInput)
        id: id;
        onChange: ((html jQuery ajax serializeForm; onComplete: ((html jQuery id: 'imageDiv') load html: [:r | self renderImageOn: r]),((html jQuery ajax script:[:s | s << ((s jQuery id: id) value: (self formatValue: theValue))]));
        callback: [:val | theValue := val];
        value: (anObject perform: aValue)];

On a change event, you trigger the serialization of the form, which invokes the regular Seaside input field callback. This callback sets the value of the input field in a temporary variable. Afterwards (onComplete of the serialization of the form via ajax, the #imageDiv gets replaced and the value of the textfield replaced with it's formated value.  Mind that a blur of a textfield also triggers the change event (http://api.jquery.com/change/).

But this triggers 3 separate ajax calls. This can me improved:

|theValue|
(html textInput)
        id: id;
        onChange: ((html jQuery ajax serializeForm; onComplete: (html jQuery ajax script:[:s | s << ((s jQuery id: 'imageDiv') html: [:r | self renderImageOn: r])). s << ((s jQuery id: id) value: (self formatValue: theValue))]);
        callback: [:val | theValue := val];
        value: (anObject perform: aValue)];

Which has 2 ajax calls: one for the serialization of the form and one 'on completion' to make the replacements.
This can be improved further to a single ajax call:

|theValue|
(html textInput)
        id: id;
        onChange: (html jQuery ajax serializeForm; script:[:s | s << ((s jQuery id: 'imageDiv') html: [:r | self renderImageOn: r])). s << ((s jQuery id: id) value: (self formatValue: theValue))]);
        callback: [:val | theValue := val];
        value: (anObject perform: aValue)];

This works because the form serialization is a 'secondary callback' and will be executed first, followed by the ajax script callback, which produces the real answer to the ajax call.

Hope this helps
Johan


On 05 Jul 2012, at 15:28, Malte Grunwald wrote:

> Hey everybody,
>
> i try to get the value of a textInput with jQuery by using  it this way:
>
> (html textInput)
>                     id: id;
>                     onBlur: html jQuery ajax serializeForm;
>                     onBlur: ((html jQuery id: 'imageDiv') load html: [:r | self renderImageOn: r]);
>                     onChange: (html jQuery new load html: [self formatValue: (html jQuery id: id)value]);
>                     callback: [...];
>                     value: (anObject perform: aValue)];
>
> but I do not get the real value in the formatValue: method. All I get is: JQueryInstance ($("#id4").val()).
> Have anybody an idea what I am doing wrong?
>
> Thank you and kind regards
>
> Malte
> _______________________________________________
> 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