I have a weird problem with this javascript (ldelim and rdelim are for curly braces when using smarty)
$('#bouton').on('click',function() {ldelim}
event.preventDefault();
$.post(url,data,function(callback_data){ldelim}
....
{rdelim});
{rdelim});
this script will reveal a div tag (‘#thisdiv’) that was invisible. Then I added
$('#thisdiv').on('click',function() {ldelim}
event.preventDefault();
$.post(url,data,function(callback_data){ldelim}
....
{rdelim});
{rdelim});
But nothing is happening on the click on ‘#thisdiv’ (even if I suppress anything in the click function on ‘#thisdiv’ and put an alert message). Someone could help ?
Edit : before the first call there is , after the first call the class ‘invisible’ us removed (class ‘invisible’ is a display none class)
#thisdivdoes not exist when this code runs – so it cannot attach the event. You need to delegate higher up the document. For example:or if there is a parent element that is there on load, you could use this as the anchor:
jquery.ondocumentation