• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Jquery - when lack of expertise causes headaches

#1
OMFG!!!!!

I just spent four hours scratching my head, over a jquery heavy page, that had just one strange behavior. I suspected what was causing it, but could not for the life of me work out what to do about it. A bound click event to the parent div was killing the one button inside (of lots of buttons inside) that didn't remove the entire element and redraw it. So when you clicked the close event, the open event fired directly afterwards. I tried removing the class, deactivating all the clicks, but other page complications meant neither of these solutions worked, or just did so much work removing and then adding the same events on multiple class elements, that I hated these solutions. I rewrote entire sections when I thought the order was 'first click applied, first click event fired', but that is not true when the click is a nested event either.

Four hours later, when I finally identified the problem clearly, frustrated at not knowing what to do, I googled "jquery stop event bubbling up" and there it was.

event.stopPropagation();

Such a simple command. Four hours of struggling and that one line fixed everything!

You live and learn. Nothing like a happy ending :-)

Paul.
Reply

#2
So true.

I read about that ones a couple of years ago.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.