[Seaside] jQuery Ajax: do something before and after

Gastón Dall' Oglio gaston.dalloglio at gmail.com
Wed Jan 23 15:20:22 UTC 2013


Hi.

Today I began to wrap button plugin of Twitter Bootstrap, so code look less
ugly:

Example:

html tbButton beSuccess;
   id: 'buttonid';
   dataLoadingText: 'Sending...';
   dataCompleteText: 'Sent';
   onClick:
      (html jQuery this tbButton loading),
      (html jQuery ajax
          serializeForm;
          callback: [ (Delay forSeconds: 3) wait. ];
          onComplete: ((html jQuery id: 'buttonid') tbButton complete));
    with: 'Send'.

or with arbitrary text states:

html tbButton beSuccess;
    id: 'buttonid';
    dataLoadingText: 'Sending...';
    data: 'ok' text: 'Sent';
    data: 'bad' text: 'No sent';
    onClick:
       (html jQuery this tbButton loading),
       (html jQuery ajax
           serializeForm;
           callback: [ (Delay forSeconds: 3) wait. ];
           onSuccess: ((html jQuery id: 'buttonid') tbButton state: 'ok');
           onError: ((html jQuery id: 'buttonid') tbButton state: 'bad'));
    with: 'Send'.


And I create an project
http://smalltalkhub.com/#!/~GastonDallOglio/TBootstrap
I know that already there an project about TwitterBootstrap in ss3 but
there is some differences with mine, I go to see asap for possibilities of
merge both projects.

Regards.


2013/1/22 Gastón Dall' Oglio <gaston.dalloglio at gmail.com>

> Hi.
>
> I use similar code to render a login button:
>
> renderLoginButton: html
>
> html tbButton beSuccess;
>     dataLoadingText: Please wait...';
>     onClick:
>         (html jQuery this call: 'button' with: 'loading'),
>         (html jQuery ajax
>             serializeForm;
>             callback: [ self login ];
>             onComplete: html javascript refresh);
>      with: 'Login'
>
> I'm using TwitterBootstrap, and I've done some classes and methods
> wrapping it. I attached those packages ().
> And see here: http://twitter.github.com/bootstrap/javascript.html#buttons
>
> Regards.
>
> PS: Why I use anchor instead of submit? that's another story :)
>
>
> 2013/1/22 Paul DeBruicker <pdebruic at gmail.com>
>
>> On 01/22/2013 08:30 AM, jtuchel wrote:
>> > s submitButton
>> >   onClick:  (
>> >                               s jQuery ajax
>> >                                       onBeforeSend: (((s jQuery class:
>> 'submit')  hide));
>> >                                       callback: [self doSomething];
>> >                                       onComplete: ((s jQuery class:
>> 'submit')  show));
>> >   with: 'Click here'.
>>
>>
>> I'd do it like this:
>>
>> s submitButton
>>   onClick: (s jQuery class: 'submit')  hide) ,  (
>>                                 s jQuery ajax
>>                                         callback: [self doSomething];
>>                                         onComplete: ((s jQuery class:
>> 'submit')  show));
>>   with: 'Click here'.
>>
>> So when clicked the button is hidden then the ajax callback is called
>> and when the ajaz callback completes the button is shown.
>>
>>
>> _______________________________________________
>> seaside mailing list
>> seaside at lists.squeakfoundation.org
>> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/seaside/attachments/20130123/9415664a/attachment.htm


More information about the seaside mailing list