I recently discover the js library modalbox (http://okonet.ru/projects/modalbox/) that is in my opinion a really powerful tool however i found a way to make it even more powerful!!
It started with the need to do some heavy DOM manipulation in the modalbox (ajax call, dynamic forms etc..). I quickly realized that the html content wasn't integrated in the DOM tree. That was not because of some sort misconception from this lib's author but a javascript's one. If you insert some html snippet in an element using javascript, this content is not parse and therefor not integrate into the DOM tree; ouch!
So i search and found this simple but efficient html parser in javascript. You now just need to insert this file into your code and modify modalbox code as following:
line 273: this.MBcontent.update(new Element("div",{style:"display: none"}).update(content)).down().show();
to:
this.MBcontent.update(new Element("div",{style:"display: none"}).(HTMLtoXML(content))).down().show();
Have fun !!
Francais:
J'ai recement decouvert la librairie js modalbox (http://okonet.ru/projects/modalbox/) que je trouve tres puissante. Toutefois, j'ai trouve un moyen de la rendre encore plus puissante !!! (un smiley du docteur d'enfer serait le bienvenu non ?)
Tout a commence alors que j'avais besoin de faire du gros DOM dans la modalbox et me suis vite rendu compte que ca ne marche pas. Pas du a un oubli de l'auteur mais tout simplement a un probleme dans le javascript. En effet, lorsque l'on injecte du code html via javascript, l'arbre DOM n'est pas mis a jour car javascript ne parse pas le contenu, il l'insert tel quel. Je me suis alors mis a la recherche d'un parser html et trouve ce simple mais efficace parser en javascript.
Maintenant nous n'avons plus qu'a inserer ce fichier dans notre code et changer la ligne suivante:
ligne 273: this.MBcontent.update(new Element("div",{style:"display: none"}).update(content)).down().show();
en:
this.MBcontent.update(new Element("div",{style:"display: none"}).(HTMLtoXML(content))).down().show();
Amusez-vous bien !!