[Seaside] Execute jQuery script upon #onAjaxComplete?
Mariano Martinez Peck
marianopeck at gmail.com
Fri Sep 23 20:58:54 UTC 2016
Well, with help from Esteban the (via chat), this ended up working as I
html document addLoadScript: (
html jQuery document onAjaxComplete:(
global: false; "to avoid inifite recursion"
script: [ :s | s << ( (html jQuery id: self classicMenuComponent
replaceWith: [:r | self classicMenuComponent systemMessageNotifier
renderContentOn: r ]
Thanks for the help!
On Fri, Sep 23, 2016 at 5:30 PM, Esteban A. Maringolo <emaringolo at gmail.com>
> Try this:
> html document addLoadScript: (
> html jQuery document onAjaxComplete: (
> (html jQuery id: self systemMessageNotifier mainDivId)
> global: false; "to avoid infinite recursion see "
> html: [:r | self systemMessageNotifier renderContentOn: r ]
>  If $.ajax() or $.ajaxSetup() is called with the global option set
> to false, the .ajaxComplete() method will not fire.
> Esteban A. Maringolo
> 2016-09-23 16:07 GMT-03:00 Mariano Martinez Peck <marianopeck at gmail.com>:
> > On Fri, Sep 23, 2016 at 3:23 PM, Esteban A. Maringolo <
> emaringolo at gmail.com>
> > wrote:
> >> 2016-09-23 12:21 GMT-03:00 Mariano Martinez Peck <marianopeck at gmail.com
> >> > The problem, as usual, is all ajax requests (and my app is now almost
> >> > everything with ajax).
> >> > I need to hook on ajax calls so that I could also re-render the
> >> > notifications components as
> >> > there could have been new notifications since the last rendering.
> >> > html
> >> > document
> >> > addLoadScript: (html jQuery document
> >> > onAjaxComplete: (
> >> > (html jQuery id: self systemMessageNotifier mainDivId)
> >> > [:r |
> >> > self systemMessageNotifier renderContentOn: r.
> >> > ]
> >> > )).
> >> > What I don't know how to do is what I want hahhaa.
> >> >I would try to avoid WebSockets for the moment. I
> >> > thought maybe doing some jQuery polling ?
> >> I don't understand what you want to implement.
> > Let's say... an admin user of the app, fires a broadcast message. This
> is a
> > message object stored in the DB. All logged users, should render the
> > messages on the main header of the app. Something like "server is going
> > be restarted in 10 minutes". Or whatever. So what I wanted to do is that
> > whenever the user "uses" the app, I would check if there are
> > and show them. With normal requests this is easy as the main messages
> > is re-rendered together with the whole page.
> > My problem is how to re-render that component (of the main header) on
> > EACH/ALL ajax callbacks. Why? Because most of my app is now with ajax,
> > of the ajax calls will re-render the "header" nor the component that
> > the alerts. So.. no alert is shown until I do a normal request.
> > So...what I don't know how to do is a generic way in which I can
> > the messages component on each ajax callback.
> >> If you want to notify something, then such notification should come as
> >> a response of the xhr and implement the ajaxComplete function handler
> >> to parse the response searching for the notification you want to
> >> display.
> > The notifications comes from a query in the DB. There could be
> > still valid and the user just entered to the app for example.
> >> The alternative is to include a <script> in every ajax response to
> >> update the notification on the client side.
> > And how could I do this in a generic way (not on every ajax response) ?
> > Thanks in advance!
> >> I also don't see how you using websockets would benefit you unless you
> >> hook the socket to an announcer.
> >> Regards,
> >> --
> >> Esteban
> >> _______________________________________________
> >> seaside mailing list
> >> seaside at lists.squeakfoundation.org
> >> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
> > --
> > Mariano
> > http://marianopeck.wordpress.com
> > _______________________________________________
> > seaside mailing list
> > seaside at lists.squeakfoundation.org
> > http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
> seaside mailing list
> seaside at lists.squeakfoundation.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the seaside