Re: Execute code after an ajax code ended

Cyril Ferlicot Delbecque <[email protected]>
Newsgroups gmane.comp.lang.smalltalk.squeak.seaside
Message-ID <[email protected]>
It's always when we send a mail that we find the answer… :)

Thank to a colleague we found a way. If someone is interested, this works:

html jQuery ajax
  callback: [ self doSomething ];
  onSuccess: (html jQuery script: [ :s |
    s << ((html jQuery id: id) load
      html: [ :ajaxHtml | self renderTableContentOn: ajaxHtml ];
      onComplete: 'componentHandler.upgradeDom();')
  ])

On 02/08/2016 10:21, Cyril Ferlicot Delbecque wrote:
> Hi,
> 
> I use the project Material Design Lite with seaside to create some
> components. With it I generate the html with Seaside and a MDL script
> replace some part of the page to initialize the components.
> 
> My problem is that for some components, I want to update them without
> refreshing the page. I found the piece of code to run to initialize the
> components but I don't know how to execute it at the right time.
> 
> The piece of code is: `componentHandler.upgradeDom();`
> 
> I tried:
> 
> html jQuery ajax
>   callback: [ self doSomething ];
>   onSuccess: (html jQuery script:
>     [ :s | s << ((html jQuery id: id) load html:
>       [ :ajaxHtml | self renderTableContentOn: ajaxHtml ]) ]) , ';
> componentHandler.upgradeDom();'
> 
> But it seems that the `componentHandler.upgradeDom()` is executed before
> the update of the html, so it is useless.
> 
> The only way I could find for now is to add a timeout of 100ms but I
> really don't like it because the user will see the page update and if
> the component take more than 100ms to be rendered it will not work.
> 
> Have someone an idea about how to make it work?
> 
> I never really did JS before using seaside so maybe the answer is stupid. :)
> 

-- 
Cyril Ferlicot

http://www.synectique.eu

165 Avenue Bretagne
Lille 59000 France

_______________________________________________
seaside mailing list
[email protected]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
signature.asc (application/pgp-signature, 801 B)
-----BEGIN PGP SIGNATURE-----

iQIcBAEBCAAGBQJXoFu5AAoJEBzpUtxBqUIDpk0QAMJ8hDQkuXRXzEYnfmJzrq2B
YfD011iGyjJ6SYdmiKVkomZLDmfu+4xhkMuDzMu78WVeAogZj+D7SKIrtW89jSWj
vTcxYIfswirR95+PvazBowF2VzKY834tmUQSHaGq1np4QSwER5AfjIB1yjSom7R5
lhFs5sE5XTneWJKENklFgxBGWXs2U/sRUFfnxKskKTuFo6+UwttgYFnK4ko1ZijT
yK9tED2VGGZA89/r1XSbRCRnN0mItvbs5D6f7O0z8Ep2cLTPfL1IlYjsuk0kiMlp
XePMdhwwlWhKz5xQBBdIzqJuT7ZKKwBkIl02jx06YNvoC356whPCD/Nh3rdBtFZs
stK1Z5Qngv97ho55vu79Pt/KPpQtbLl24F+x3D6t8XTELSlr6uetFOQSGfQ75jIL
ASoX7Ra5t+gPWS4A0WYcCjXBIC5F0vgaFZFlyDkcm6mwhc0hOReYVhF1DoNI8mI4
BHJpUjgy65vGy7uLVagTdDIeNUAXYbmq1AfyPOiAxOSRx8xYuYpfjnGWhcp4pLLc
INyH6fMpu4g5AXgTPCgMWJ0Bijgu3xm0ucMgjFZNh4/4wV2qdadR2HUzYJOtg3f/
qijVCCmaw6/ylnaaHX2ui43hJAXJg4YJJzZyj8kNJD96aKypnU/l2I9rq6zUXO3o
iidJiD1yM69MJ+YrKbC7
=npko
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.