<div dir="ltr">Well, with help from Esteban the (via chat), this ended up working as I expected:<div><br></div><div><br></div><div><div>html document addLoadScript: (</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">                </span>html jQuery document onAjaxComplete:(</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">                        </span>html jQuery </div><div><span class="gmail-Apple-tab-span" style="white-space:pre">                                </span>ajax</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">                                </span>global: false; "to avoid inifite recursion"</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">                                </span>script: [ :s | s << ( (html jQuery id: self classicMenuComponent systemMessageNotifier mainDivId) </div><div><span class="gmail-Apple-tab-span" style="white-space:pre">                                                                                                </span>replaceWith: [:r | self classicMenuComponent systemMessageNotifier renderContentOn: r ]</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">                                                                                        </span>) ]</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">                                </span></div><div><span class="gmail-Apple-tab-span" style="white-space:pre">                </span>)</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">        </span>)</div></div><div><br></div><div><br></div><div><br></div><div>Thanks for the help!</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Sep 23, 2016 at 5:30 PM, Esteban A. Maringolo <span dir="ltr"><<a href="mailto:emaringolo@gmail.com" target="_blank">emaringolo@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Try this:<br>
<br>
html document addLoadScript: (<br>
<span class=""> html jQuery document onAjaxComplete: (<br>
(html jQuery id: self systemMessageNotifier mainDivId)<br>
</span> load<br>
global: false; "to avoid infinite recursion see [1]"<br>
html: [:r | self systemMessageNotifier renderContentOn: r ]<br>
)<br>
).<br>
<br>
[1] If $.ajax() or $.ajaxSetup() is called with the global option set<br>
to false, the .ajaxComplete() method will not fire.<br>
<<a href="http://api.jquery.com/ajaxComplete/" rel="noreferrer" target="_blank">http://api.jquery.com/<wbr>ajaxComplete/</a>><br>
<span class="HOEnZb"><font color="#888888">Esteban A. Maringolo<br>
</font></span><div class="HOEnZb"><div class="h5"><br>
<br>
2016-09-23 16:07 GMT-03:00 Mariano Martinez Peck <<a href="mailto:marianopeck@gmail.com">marianopeck@gmail.com</a>>:<br>
><br>
><br>
> On Fri, Sep 23, 2016 at 3:23 PM, Esteban A. Maringolo <<a href="mailto:emaringolo@gmail.com">emaringolo@gmail.com</a>><br>
> wrote:<br>
>><br>
>> 2016-09-23 12:21 GMT-03:00 Mariano Martinez Peck <<a href="mailto:marianopeck@gmail.com">marianopeck@gmail.com</a>>:<br>
>> > The problem, as usual, is all ajax requests (and my app is now almost<br>
>> > everything with ajax).<br>
>> > I need to hook on ajax calls so that I could also re-render the<br>
>> > notifications components as<br>
>> > there could have been new notifications since the last rendering.<br>
>><br>
>> > html<br>
>> > document<br>
>> > addLoadScript: (html jQuery document<br>
>> > onAjaxComplete: (<br>
>> > (html jQuery id: self systemMessageNotifier mainDivId) replaceWith:<br>
>> > [:r |<br>
>> > self systemMessageNotifier renderContentOn: r.<br>
>> > ]<br>
>> > )).<br>
>><br>
>> > What I don't know how to do is what I want hahhaa.<br>
>> >I would try to avoid WebSockets for the moment. I<br>
>> > thought maybe doing some jQuery polling ?<br>
>><br>
>> I don't understand what you want to implement.<br>
><br>
><br>
> Let's say... an admin user of the app, fires a broadcast message. This is a<br>
> message object stored in the DB. All logged users, should render the active<br>
> messages on the main header of the app. Something like "server is going to<br>
> be restarted in 10 minutes". Or whatever. So what I wanted to do is that<br>
> whenever the user "uses" the app, I would check if there are notifications<br>
> and show them. With normal requests this is easy as the main messages header<br>
> is re-rendered together with the whole page.<br>
><br>
> My problem is how to re-render that component (of the main header) on<br>
> EACH/ALL ajax callbacks. Why? Because most of my app is now with ajax, none<br>
> of the ajax calls will re-render the "header" nor the component that renders<br>
> the alerts. So.. no alert is shown until I do a normal request.<br>
><br>
> So...what I don't know how to do is a generic way in which I can re-render<br>
> the messages component on each ajax callback.<br>
><br>
>><br>
>><br>
>> If you want to notify something, then such notification should come as<br>
>> a response of the xhr and implement the ajaxComplete function handler<br>
>> to parse the response searching for the notification you want to<br>
>> display.<br>
><br>
><br>
> The notifications comes from a query in the DB. There could be notifications<br>
> still valid and the user just entered to the app for example.<br>
><br>
>><br>
>><br>
>> The alternative is to include a <script> in every ajax response to<br>
>> update the notification on the client side.<br>
><br>
><br>
><br>
> And how could I do this in a generic way (not on every ajax response) ?<br>
><br>
> Thanks in advance!<br>
><br>
>><br>
>><br>
>> I also don't see how you using websockets would benefit you unless you<br>
>> hook the socket to an announcer.<br>
>><br>
>> Regards,<br>
>><br>
>> --<br>
>> Esteban<br>
>> ______________________________<wbr>_________________<br>
>> seaside mailing list<br>
>> <a href="mailto:seaside@lists.squeakfoundation.org">seaside@lists.<wbr>squeakfoundation.org</a><br>
>> <a href="http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside" rel="noreferrer" target="_blank">http://lists.squeakfoundation.<wbr>org/cgi-bin/mailman/listinfo/<wbr>seaside</a><br>
><br>
><br>
><br>
><br>
> --<br>
> Mariano<br>
> <a href="http://marianopeck.wordpress.com" rel="noreferrer" target="_blank">http://marianopeck.wordpress.<wbr>com</a><br>
><br>
> ______________________________<wbr>_________________<br>
> seaside mailing list<br>
> <a href="mailto:seaside@lists.squeakfoundation.org">seaside@lists.<wbr>squeakfoundation.org</a><br>
> <a href="http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside" rel="noreferrer" target="_blank">http://lists.squeakfoundation.<wbr>org/cgi-bin/mailman/listinfo/<wbr>seaside</a><br>
><br>
______________________________<wbr>_________________<br>
seaside mailing list<br>
<a href="mailto:seaside@lists.squeakfoundation.org">seaside@lists.<wbr>squeakfoundation.org</a><br>
<a href="http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside" rel="noreferrer" target="_blank">http://lists.squeakfoundation.<wbr>org/cgi-bin/mailman/listinfo/<wbr>seaside</a><br>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature">Mariano<br><a href="http://marianopeck.wordpress.com" target="_blank">http://marianopeck.wordpress.com</a><br></div>
</div>