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