Questions tagged [jquery-delegate]

`.delegate()` is a function within jQuery JS framework, that attaches events to the specified elements within specified existing root element, even if they do not exist at the time events are attached.

.delegate() works similarly to .live() and is documented on the jQuery documentation page for .delegate().

31 questions
8
votes
3 answers

jQuery .on() instead of .delegate() without event

Is it possible to use jquery .on() method instead of .delegate() when there is no event to be listened to? According to the .on() documentation: .on( events [, selector] [, data] , handler(eventObject) ) The events argument is not optional. The…
KoU_warch
  • 2,160
  • 1
  • 25
  • 46
5
votes
3 answers

Newly added elements using delegate() won't bind jscolor.js

I have a simple form, where each line consists of 3 input fields. on one of those fields, I use jscolor.js (field has a class="color" and thus binds the JS). However, when I add new lines using jQuery's delegate(), the input field doesn't bind the…
AlexW
  • 103
  • 1
  • 6
5
votes
3 answers

JQUERY event firing more than one time, when using delegate jquery

I am using delegate jquery in my code, but when it fire some event it fire more than once, I know It is because i have bind the event of optionclicked class to the boxes-main class but i am in a situation that i have to bind these classes with each…
Naveen Singh
  • 395
  • 1
  • 3
  • 17
4
votes
3 answers

what is behind of delegate() and live() method?

What is behind of delegate() and live() methods in jQuery that give them the ability of working for current and future elements within the page?
hd.
  • 17,596
  • 46
  • 115
  • 165
3
votes
1 answer

jQuery set value to delegated input fields

I have the HTML code as follows.
Ashif Shereef
  • 454
  • 1
  • 8
  • 24
2
votes
1 answer

jQuery event delegation for when a selector comes into existence?

Let's say I want to change the text of any new particular DOM elements that are created. E.g.: (not real API, I realize) $('body').on('creation', '.change-this', function() { $(this).text('Boom!'); }); So if I programmatically create
CaptSaltyJack
  • 15,283
  • 17
  • 70
  • 99
2
votes
2 answers

Is there a way to unbind a delegated event on each element instance?

What I need to do is get the functionality of jQuery.one on each matched element using delegation. As you can see clicking on the link for "Baz" or "Bat" appends "(removed)" multiple times. On the other hand clicking the link for "Foo" executes the…
prodigitalson
  • 60,050
  • 10
  • 100
  • 114
2
votes
1 answer

Issue with .delegate and .closest

$('document').delegate('.seeMore a', "click", function() { var $allTabs = $(this).closest('.globalTabs').find('.allTabs'); $allTabs.slideDown('slow'); }); The DOM elements are:
Jason
  • 7,612
  • 14
  • 77
  • 127
2
votes
4 answers

Am I understanding the jQuery delegate function correctly?

I know that a div will appear at some point in my page's future DOM, and I know the id of it (it's generated by SharePoint javascript) - is it possible for me to use jQuery delegate to attach an event handler to this div prior to it existing in the…
user1017882
1
vote
4 answers

Need help understanding jquery delegate() function

I'm having a hard time understanding the syntax of the .delegate function of jquery. Let's say I have the following: $(".some_element_class").delegate("a", "click", function(){ alert($(this).html()); }); I know that the a element is the…
user765368
  • 19,590
  • 27
  • 96
  • 167
1
vote
2 answers

Get elements of HTML TR when a button in the row is clicked

I have the following Dynamic HTML row.
Alex Nilson
1
vote
1 answer

JQuery replacement of live :: `delegate` or `on`

According to the jQuery API Description: live is completely removed in latest version. But its been used in our projects extensively. For example: $('div.collapsed').live('mouseover', function () { …
Muntasim
  • 6,689
  • 3
  • 46
  • 69
1
vote
3 answers

Using jQuery delegate() to replace live()

I currently am creating content using jQuery. Live(), according to the jQuery API Description: Attach an event handler for all elements which match the current selector, now and in the future.. I need this line of code to work in the future. …
Jacob Raccuia
  • 1,666
  • 1
  • 16
  • 25
1
vote
1 answer

How to identify what object triggered the jQuery click event within delegate code

I have a very simple jsFiddle that use jQuery caching and delegate. How can I make handler dynamic enough that when user clicks the first group checkbox, it highlights only the rows below it and when user selects the second group checkbox, it should…
Sri Reddy
  • 6,832
  • 20
  • 70
  • 112
0
votes
1 answer

Using .delegate or .live with if statements (if empty do blah blah blah) on dynamic content

2 fold issue. I need to hide an element(A) if another element(B) is empty and show A if B has elements within. And I need to do this on elements loaded dynamically. So I tried: $(document).ready(function() { if ($('#mapDirections').html().trim())…
Jason
  • 7,612
  • 14
  • 77
  • 127
1
2 3