[Seaside] Javascript calls through jQuery

Esteban A. Maringolo emaringolo at gmail.com
Mon Mar 3 14:06:03 UTC 2014


Let's add a twist to this... I want to a have a recurrent polling to
the #json: callback I implemented above.

I had the following load script written in plain JS:

        (function getStoresStatus(){
                $.ajax({url: '/ps/rest/store-status', dataType: 'json'}).done(
                        function(response){
                                jQuery.each(response, function(index, value){
                                        updateStoreMarker(value)});
                                setTimeout(getStoresStatus,30000)
                        }
                );
        }());


How can I do the same using Seaside Jquery functions?

Regards!

Esteban A. Maringolo


2014-03-03 10:27 GMT-03:00 Esteban A. Maringolo <emaringolo at gmail.com>:
> Good day Johan,
>
> I thought WAButtonTag was push by default, I didn't check.
>
> I moved the #json: method from JQGetJson to JQAjax, and chained
> #serializeForm and #json: on the same ajax object and it worked.
> Thanks!
>
> I don't know how Seaside manages to read the serialized form values
> from the query string, but in this very moment I don't care much
> either :)
>
> By now it works as expected. I'll surely come back later with more questions.
>
>
> Thanks again.
>
> ps: Is the #json: method going to be added to Seaside-Jquery main trunk?
> Esteban A. Maringolo
>
>
> 2014-03-03 4:07 GMT-03:00 Johan Brichau <johan at inceptive.be>:
>> Esteban,
>>
>> Mind that you can combine these ajax calls in the following way:
>>
>> html form: [
>> "...snipped code"
>>  html button
>>         bePush;
>>         onClick:  (html jQuery ajax
>>                   serializeForm;
>>                   json: [:json | json object: [ ] ];
>>                  onSuccess: 'console.log(arguments[0])');
>>    with: 'Filter!'
>> ]
>>
>> cheers
>> Johan
>>
>> On 03 Mar 2014, at 07:21, Johan Brichau <johan at inceptive.be> wrote:
>>
>>>
>>> On 03 Mar 2014, at 02:09, Esteban A. Maringolo <emaringolo at gmail.com> wrote:
>>>
>>>> Any suggestion?
>>>
>>> That's because the button is triggering a submit. Change it to a push button as follows:
>>>
>>> html form: [
>>> "...snipped code"
>>> html button
>>>   onClick:  (html jQuery ajax
>>>                  serializeForm;
>>>                  onComplete: (
>>>                    html jQuery getJson
>>>                      json: [:json | self renderJsonResponseOn: json ];
>>>                      onSuccess: 'console.log(arguments[0])'));
>>>   with: 'Filter!'
>>> ]
>>>
>>>> ps: Is there a way to generate pretty-printed JS and HTML source?
>>>
>>> afaik, you have to use the browser development tools for that:
>>>
>>> https://plus.google.com/+AddyOsmani/posts/Q7t2U51G7YR
>>>
>>> cheers
>>> Johan
>>
>> _______________________________________________
>> seaside mailing list
>> seaside at lists.squeakfoundation.org
>> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside


More information about the seaside mailing list