1

i'm working with drupal and the current version of jQuery for drupal is the 1.4, but in the current HTML the developer used the ON(). function, how can i adapt this for 1.4?

$('body').on('click.button.data-api', '[data-toggle^=button]', function (e) {
                var $btn = $(e.target)
                if (!$btn.hasClass('btn')) $btn = $btn.closest('.btn')
                $btn.button('toggle')
Rommel Castro
  • 460
  • 4
  • 13

2 Answers2

1

jQuery 1.3 used 'live', before being superseeded by on http://api.jquery.com/live/

leopic
  • 2,958
  • 2
  • 27
  • 42
  • Taken from the first paragraph of your link: "Users of older versions of jQuery should use .delegate() in preference to .live()." - I'd suggest using `.delegate()` if it's supported in 1.4, but I don't know if it'd make much of a change. Probably not. Edit: `.delegate` is supported in version 1.4.2+. – Fabrício Matté May 12 '12 at 02:28
  • Yup that's the reason why I didn't suggest delegate, I assumed he was using 1.4, but good catch :) – leopic May 12 '12 at 02:47
  • I see, +1 as your solution is suitable for both cases. :) – Fabrício Matté May 12 '12 at 02:51
1

Have you checked into the .bind('click') event?

http://api.jquery.com/bind/

$('#foo').bind('click', function() { alert('User clicked on "foo."'); });

Chase
  • 29,019
  • 1
  • 49
  • 48