Because <script>s are not executed in ajax loaded content. It is a browser thing. It is not in the specs. You can do
<div class="one" id="a" onclick="jQuery('.two').slideToggle()">Hello</ div> <div class="two" id="b">World</div> this will work because the code is executed onclick and not on ajax load. Massimo On May 7, 12:22 pm, salbefe <salb...@gmail.com> wrote: > Hello, > > First of all, I think I should say sorry because probably this is not > the correct place to post the following problem but I'm getting crazy. > > My problem with jquery is as follows: > > On a view I have a form that is submited via web2py ajax method. > Something like this > > [....] > <form id="do_busqueda"> > > ......... > <div> > <input type="submit" name="btnSubmit" id="btnSubmit" > value="Buscar" class="btn" /> > </div> > </form> > <div id="empleados_list"></div> > > This form is submited like this: > > <script> > jQuery('#do_busqueda').submit(function(){ > .................................... > ................................... > ajax("{{=URL(r=request, c='presencia', > f='do_busqueda')}}",id_list, 'empleados_list'); > return false; > }); > </script> > > And this works fine. On <div id="empleados_list"></div> appears a > table filled with an employees list that is the view that the function > do_busqueda builds. To try to explain better I have changed my view > and I have replaced it by the code that is on the web2py book (2nd > ed.) on pag 268. > > Now the fucntion do_busqueda renders this view: > > <div class="one" id="a">Hello</div> > <div class="two" id="b">World</div> > <script> > jQuery('.one').click(function(){jQuery('.two').slideToggle()}); > </script> > > And...when is rendered does not work. In my case, the table that is > rendered by the view do_busqueda.html has a checkbox and what I'm > trying to do is that when the user clicks on a checkbox an alert > message box should be displayed. I do not understand why this code > does not work. Why is not executed?? Any ideas??? > > Thanks in advance