<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Sep 23, 2016 at 3:23 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"><span class="">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; The problem, as usual, is all ajax requests (and my app is now almost everything with ajax).<br>
&gt; I need to hook on ajax calls so that I could also re-render the notifications components as<br>
&gt; there could have been new notifications since the last rendering.<br>
<br>
</span><span class="">&gt; html<br>
&gt; document<br>
&gt; addLoadScript: (html jQuery document<br>
&gt;                      onAjaxComplete: (<br>
&gt;   (html jQuery id: self  systemMessageNotifier mainDivId)  replaceWith: [:r |<br>
&gt; self systemMessageNotifier renderContentOn: r.<br>
&gt; ]<br>
&gt; )).<br>
<br>
</span><span class="">&gt; What I don&#39;t know how to do is what I want hahhaa.<br>
&gt;I would try to avoid WebSockets for the moment. I<br>
&gt; thought maybe doing some jQuery polling ?<br>
<br>
</span>I don&#39;t understand what you want to implement.<br></blockquote><div><br></div><div>Let&#39;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 active messages on the main header of the app. Something like &quot;server is going to be restarted in 10 minutes&quot;. Or whatever. So what I wanted to do is that whenever the user &quot;uses&quot; the app, I would check if there are notifications and show them. With normal requests this is easy as the main messages header is re-rendered together with the whole page.</div><div> </div><div>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, none of the ajax calls will re-render the &quot;header&quot; nor the component that renders the alerts. So.. no alert is shown until I do a normal request. </div><div><br></div><div>So...what I don&#39;t know how to do is a generic way in which I can re-render the messages component on each ajax callback. </div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<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></blockquote><div><br></div><div>The notifications comes from a query in the DB. There could be notifications still valid and the user just entered to the app for example. </div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
The alternative is to include a &lt;script&gt; in every ajax response to<br>
update the notification on the client side.<br></blockquote><div><br></div><div><br></div><div>And how could I do this in a generic way (not on every ajax response) ?</div><div><br></div><div>Thanks in advance!</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
I also don&#39;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>
</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></div>