Execute code after an ajax code ended

Cyril Ferlicot Delbecque <[email protected]>
Newsgroups gmane.comp.lang.smalltalk.squeak.seaside
Message-ID <[email protected]>
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-----

iQIcBAEBCAAGBQJXoFgTAAoJEBzpUtxBqUIDB9cP/2JVwR7vsD8k8vhtNrIXmRko
ua1nL27iNb4UFRAp9KerG0D3eUPikX+jI2RiVIVMMhzrTOCZEEdIaNFEICWax3GE
PbXLZNM/k/nLv9/26Y1v9KH67D8gRr2q+D3n9DglqkOQptVIncUGRfUnN5/IDLOv
C9fFGaixMKHDXiviQXfj5VTsRIsPw1SogQ+5SUfbEtia2lZxsoSr0urQikLM9L76
WlPLoZEV1cysUQSXHIqocmjUDXvmb4tOH5AguTyEa48loxa/mP9gMYNbEZWdxTYC
7KFTBY9JpyxOOQW59ci8Jb8GvgJPhmSVimBhBW06oneWc8gVCMNcaP4eAUoQxMQ6
5gMIk7MfhHcPMotpSk2xUTIm4qHebh+ZXBFOjbTFwEdiDiyWsKrODhKpOKoNt7x8
lpQtZRfadtHSBHfFx5bm88/5Xssf/lLmsd7K6JmdZDo09HViLADBsXfI2jNczXto
AmXEFJoEi0k/VpUq7R0j+7tr9SC4ce38J9RIBnqdAK/NFGEa8ofPn3m1YuC1Isvd
uTTvLEyIt43ArtPYxpYmhEYKbXMHbhx8ER77slm9nYwiwBMuDLH47HVg06u7WJPI
NWe1bvdFe/eP+IDhVWlCIZ4Akw6PaFDz/8ZAw7rUEF9smybTmvJjDv4XbbAEU6M1
cpya9deWCAHJzdaub8uZ
=yGaK
-----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.