Bonjour a tous,
Je cherche a réaliser un "Hook" un genre de callback qui serait appellé a chaque fois que l'on set ou get un attribut avec .attr();
je suis tombé sur cet article
http://blog.rodneyrehm.de/archives/11-jQuery-Hooks.html
Mais suite a de très nombreux tests infructueux j'ai décidé de m'adresser a vous.
un bout de JS de mon hook:
1 2 3 4 5 6 7 8 9 10 11 12 13
| $.attrHooks.open = {
get: function(elem) {
alert("get hook is hooking");
return true;
},
set: function(elem) {
alert("set hook is hooking");
return true;
}
}; |
Le code JS appellant
1 2
| var data = $('.hooktest').attr('testattribhook');
alert(data); |
HTML
<div class="hooktest" testattribhook="peu importe"></div>
J'ai testé tout ca dans tous les sens... ca n'a pas l'air de marcher... Pas d'erreur de syntaxe non plus...
Une tite idée?
Merci pour votre aide!
Partager