Re: ajax onBlur callback with load html: [...]
Bob Nemec <[email protected]> Wed, 15 Sep 2021 21:40:36 +0000 (UTC)
| Newsgroups | gmane.comp.lang.smalltalk.squeak.seaside |
|---|---|
| Message-ID | <[email protected]> |
--===============4754729358018477043==
Content-Type: multipart/alternative;
boundary="----=_Part_408415_942973379.1631742036910"
------=_Part_408415_942973379.1631742036910
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
=20
Wow, this is proving to be challenge. The problem is that in=C2=A0JQAjax>>p=
rocessCallback #callback is sometimes nil. When it is, the button press cal=
lback is not processed and the button has to be pressed again. But, if the =
onBlur of the text input field has a 100ms delay, the #callback value is no=
t nil and the button callback works all the time. Which is especially frust=
rating because adding diagnostic traces slows down the first callback enoug=
h for things to work.=C2=A0
This is pushing me to the edge of my Seaside knowledge. I will try this sam=
e example with the latest Seaside code on Pharo. If it works, I'll work on =
getting us updated (we develop in VW but deploy on GS). If not, I'll have a=
nice packaged problem to raise on the Seaside part of the Pharo Discord ch=
annel.=C2=A0
Bob
On Tuesday, September 14, 2021, 08:58:31 a.m. EDT, Karsten Kusche <kars=
[email protected]> wrote: =20
=20
#yiv0857676699 body{font-family:Helvetica, Arial;font-size:13px;}Hi Bob,
We use onBlur to get the data from input fields and to refresh the state of=
the view. The problem comes up if a button is included in the refresh: the=
ajax callback from that button is not handled (which makes sense due to th=
e jQuery load), so the user has to press the button again.
I=E2=80=99d say it actually doesn=E2=80=99t make any sense. Your callbacks =
are registered, they should work regardless. You could use the Web-Browser=
=E2=80=99s network tool/profiler to see which event-handler is fired and wh=
at network requests are made. Maybe one of the requests doesn=E2=80=99t com=
e through correctly and you can investigate that further.=C2=A0
Some things you should also consider: when you use render HTML-Snippets tha=
t contain Javascript (like new click-handlers), Seaside will automatically =
add these inside a <script>-tag at the end of this snippet and inject that =
into your DOM at the place where you inject the HTML. In your case you shou=
ld have a <script>-tag at the end of your #testDiv.=C2=A0
I=E2=80=99m not entirely sure about this, but iirc replacing that script-ta=
g will also remove all event-handlers that were registered as part of this =
tag. On the other hand replacing the <script> also means replacing the <but=
ton> so you should still have a working button in any case=E2=80=A6 like i =
said, it doesn=E2=80=99t really make much sense.
Karsten
=20
------=_Part_408415_942973379.1631742036910
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<html><head></head><body><div class=3D"ydpb0c0ebbayahoo-style-wrap" style=
=3D"font-family:lucida console, sans-serif;font-size:13px;"><div></div>
<div><br></div><div dir=3D"ltr" data-setdir=3D"false">Wow, this is =
proving to be challenge. The problem is that in <span>JQAjax>>pr=
ocessCallback #<span>callback is sometimes nil. When it is, the button pres=
s callback is not processed and the button has to be pressed again. But, if=
the onBlur of the text input field has a 100ms delay, the #callback value =
is not nil and the button callback works all the time. Which is especially =
frustrating because adding diagnostic traces slows down the first callback =
enough for things to work. </span></span></div><div dir=3D"ltr" data-s=
etdir=3D"false"><span><span><br></span></span></div><div dir=3D"ltr" data-s=
etdir=3D"false"><span><span>This is pushing me to the edge of my Seaside kn=
owledge. I will try this same example with the latest Seaside code on Pharo=
. If it works, I'll work on getting us updated (we develop in VW but deploy=
on GS). If not, I'll have a nice packaged problem to raise on the Seaside =
part of the Pharo Discord channel. </span></span></div><div dir=3D"ltr=
" data-setdir=3D"false"><span><span><br></span></span></div><div dir=3D"ltr=
" data-setdir=3D"false"><span><span>Bob</span></span></div><div dir=3D"ltr"=
data-setdir=3D"false"><span><span><br></span></span></div>
=20
</div><div id=3D"yahoo_quoted_2112089454" class=3D"yahoo_quoted">
<div style=3D"font-family:'Helvetica Neue', Helvetica, Arial, s=
ans-serif;font-size:13px;color:#26282a;">
=20
<div>
On Tuesday, September 14, 2021, 08:58:31 a.m. EDT, Kars=
ten Kusche <[email protected]> wrote:
</div>
<div><br></div>
<div><br></div>
<div><div id=3D"yiv0857676699"><style>#yiv0857676699 body{f=
ont-family:Helvetica, Arial;font-size:13px;}</style><div>
<div style=3D"font-family:Helvetica, Arial;font-size:13px;">Hi Bob,</div>
<div class=3D"yiv0857676699yqt6264543426" id=3D"yiv0857676699yqtfd02179"><d=
iv style=3D"font-family:Helvetica, Arial;font-size:13px;"><br clear=3D"none=
">
</div>
</div><div><div class=3D"yiv0857676699yqt6264543426" id=3D"yiv0857676699yqt=
fd06452">
</div><blockquote class=3D"yiv0857676699clean_bq" type=3D"cite" style=3D"fo=
nt-family:Helvetica, Arial;font-size:13px;font-style:normal;font-weight:nor=
mal;letter-spacing:normal;text-indent:0px;text-transform:none;white-space:n=
ormal;word-spacing:0px;text-decoration:none;"><div class=3D"yiv0857676699yq=
t6264543426" id=3D"yiv0857676699yqtfd95783">
<span>
</span><div>We use onBlur to get the data from input fields and to refresh =
the state of the view. The problem comes up if a button is included in the =
refresh: the ajax callback from that button is not handled (which makes sen=
se due to the jQuery load), so the user
has to press the button again.</div></div>
</blockquote>
</div>
<p>I=E2=80=99d say it actually doesn=E2=80=99t make any sense. Your callbac=
ks are registered, they should work regardless. You could use the Web-Brows=
er=E2=80=99s network tool/profiler to see which event-handler is fired and =
what network requests are made. Maybe one of the requests
doesn=E2=80=99t come through correctly and you can investigate that furthe=
r. </p>
<p>Some things you should also consider: when you use render HTML-Snippets =
that contain Javascript (like new click-handlers), Seaside will automatical=
ly add these inside a <script>-tag at the end of this snippet and inj=
ect that into your DOM at the place where
you inject the HTML. In your case you should have a <script>-tag at =
the end of your #testDiv. </p>
<p>I=E2=80=99m not entirely sure about this, but iirc replacing that script=
-tag will also remove all event-handlers that were registered as part of th=
is tag. On the other hand replacing the <script> also means replacing=
the <button> so you should still have a working
button in any case=E2=80=A6 like i said, it doesn=E2=80=99t really make mu=
ch sense.</p>
<p>Karsten</p><div class=3D"yiv0857676699yqt6264543426" id=3D"yiv0857676699=
yqtfd17937">
<div></div>
</div></div></div></div>
</div>
</div></body></html>
------=_Part_408415_942973379.1631742036910--
--===============4754729358018477043==
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: base64
Content-Disposition: inline
X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX18Kc2Vhc2lkZSBt
YWlsaW5nIGxpc3QKc2Vhc2lkZUBsaXN0cy5zcXVlYWtmb3VuZGF0aW9uLm9yZwpodHRwOi8vbGlz
dHMuc3F1ZWFrZm91bmRhdGlvbi5vcmcvY2dpLWJpbi9tYWlsbWFuL2xpc3RpbmZvL3NlYXNpZGUK
--===============4754729358018477043==--