[Seaside] Execute jQuery script upon #onAjaxComplete?

Mariano Martinez Peck marianopeck at gmail.com
Fri Sep 23 15:21:34 UTC 2016


Hi guys,

I am trying to make some alerts/notifications to be displayed to users. For
some internal reasons, these notifications are at server side. I have main
component that on the #renderContentOn: does the render of the needed
notifications.

This works fine for normal requests as any "interaction" from the user with
the app, will make a normal request causing a re-render of everything,
included the notification component.

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.

I tried the following:

html
document
addLoadScript: (html jQuery document
                     onAjaxComplete: (
  (html jQuery id: self  systemMessageNotifier mainDivId)  replaceWith: [:r
|
self systemMessageNotifier renderContentOn: r.
]
)).

But obviously that doesn't work because the onAjaxComplete: scripts ends
being a hardcoded to the html of the current systemMessageNotifier
component. In other words, the #renderContentOn: of the
systemMessageNotifier is called only once...and not on every ajax complete.
And I understand why.

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 ?

Thoughts?

Thanks in advance,





-- 
Mariano
http://marianopeck.wordpress.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/seaside/attachments/20160923/4caa4cf7/attachment.htm


More information about the seaside mailing list