Hi everyone,
I found the mistake, although I'm not quite sure why it works, but it
does.
Change this:
__app.js___________________________________
5 $(document).ready(function() {
6 $("#my_div").click(function () {
7 do_something
8 });
9 });
To this:
5 $(document).ready(function() {
6 $("#my_div").click( do_something() );
7 function do_something (){...};
8 });
Thanks for the inspiration!
Nacho
On Dec 14, 7:25 pm, "Michael Geary" <[email protected]> wrote:
> It's pretty hard to tell what might be wrong from the code snippet. Can you
> post a link to a test page instead?
>
> -Mike
>
> > From: nachocab
>
> > You're right:
> > __test.js__________________________
> > 1 test("bind div again", function() {
> > 2 $("#my_div").click();
> > 3 ok( check_if_it_worked, "working") //Here it fails!
> > 4 });
> > __app.js___________________________________
> > 5 $(document).ready(function() {
> > 6 $("#my_div").click(function () {
> > 7 do_something
> > 8 });
> > 9 });
>
> > The test fails because line 2 never calls the function in
> > line 7. Any ideas? I'm clueless... Thanks!
>
> > On Dec 14, 2:59 pm, "Derrick Jackson" <[email protected]>
> > wrote:
> > > Nacho,
>
> > > I am new to jQuery and may not have a lot to offer, but does the
> > > second function actually fail or does it not run?
>
> > > On 12/14/08, nachocab <[email protected]> wrote:
>
> > > > Hi,
> > > > I have a test that passes if I run it by itself, but if I
> > duplicate
> > > > the code and run both of them, the second one fails. What
> > am I doing
> > > > wrong?
>
> > > > __test.js___________________________________
> > > > test("bind div", function() {
> > > > $("#my_div").click();
> > > > ok( check_if_it_worked, "working")
> > > > });
>
> > > > test("bind div again", function() {
> > > > $("#my_div").click();
> > > > ok( check_if_it_worked, "working") //Here it fails!
> > > > });
>
> > > > __app.js___________________________________
> > > > $(document).ready(function() {
> > > > $("#my_div").click(function () {
> > > > do_something
> > > > });
> > > > });
>
> > > > Thanks!
>
> > > > Nacho
>
> > > --
> > > Sent from Gmail for mobile | mobile.google.com