I'm trying to build a greasemonkey script which will dynamically create tables of data based on user interaction with... other dynamically created tables of data. My problem is that I'm having to make two passes every time I create a table: one to create the table, and another to go grab all of the objects in the table I want to add even...
I display a bunch of posts from users on a page. I have the main parent div with the class name 'posts' and each post is outputted in a div with class name 'row' inside of it. So there's a whole lot of div.row's inside the div.posts. Each look like this.
<div class="row clearfix">
<div class="left-column">
<img src="..." title="" />
...
I'd like to try out a new JavaScript library. Having used (and loved) jQuery 1.3's "Live" events, I'd prefer the next library I try to have event delegation built in to the event system. Wikipedia's JS Library Comparison falls down on the job here.
Looks like MooTools is getting it in 2.0. What about the others?
I'm making this communi...
Normally you write a handler for a button click like this:
$(document).ready(function()
{
$("button").click(function()
{
doSomething();
});
});
But in the case of an event delegator, to respond to an event with a function such as this:
function doSomething(event)
{
if (ev.target.id == 'button1' )
{
/...
I'm confused about when you should use event delegation as opposed to out-of-the-box JQuery event handling.
I'm always tempted to use an event handler because it's so easy in JQuery:
For example:
$("button#submit").click(function () {
$(this).css("disabled", "true");
});
Event delegation is not really that much more compl...
If my markup looks like this:
<button id="button-1" class="nice">
<button id="button-2" class="nice">
<button id="button-3" class="nice">
and I define the following jQuery:
$(".nice").click(function () {
// something happens
});
How many event listeners are established? 1 or 3?
If I have 1000 buttons instead of 3, should I us...
I have a page with elements similar to this:
<div id='things'>
<div class='thing'>
<div class='activator'>
<span>Some text</span>
</div>
</div>
</div>
The code is similar to this:
$('things').observe(click, function(event) {
var e = event.element();
if (e.match('.activator')) {
doSo...
I have this code for some elements to be dropped
var $tab_items = $("ul:first li",$tabs).droppable{ tolerance: 'touch' ,....
and it´s work ok, but the problem it´s when I load another button by ajax or by javascript,
don´t work because the new element don´t have binding for this event.
In other similar situation I found a solution usi...
Update
Can anyone please explain event delegation in JavaScript and how is it useful?
Original:
Delegation in programming.
Can anyone please explain delegation and how is it useful?
...
I have a div
<div class="myDiv">
<a href="#" class="myLink">somelink</a>
<div class="anotherDiv">somediv</div>
</div>
Now, using event delegation and the concept of bubbling I would like to intercept clicks from any of myDiv, myLink and anotherDiv.
According to best practices this could be done by listening for clicks globally (h...
I'm developing an ajax heavy web app, and would like to have textarea's (with class="ui-richtext") automatically initialize TinyMCE.
This is easy for textarea's that are loaded normally, but how about for content that is loaded AFTER the fact using ajax?
I was thinking something along these lines: (i'm using jquery)
$("textarea.ui-ric...
Hi
I am trying to stop some events but stopPropagation does not work with "live" so I am not sure what to do. I found this on their site.
Live events do not bubble in the
traditional manner and cannot be
stopped using stopPropagation or
stopImmediatePropagation. For example,
take the case of two click events -
one bound to...
Is it possible to have event delegation using the HTML5 data attributes in MooTools?
The HTML structure I have is:
<div id="parent">
<div>not selectable</div>
<div data-selectable="true">selectable</div>
<div>not selectable either.</div>
<div data-selectable="true">also selectable</div>
</div>...
Would really appreciate if anyone can help me figure out why I am unable to fire events programmatically when using event delegation in MooTools (from the Element.Delegation class).
There is a parent <div> that has a change listener on some child <input> elements. When the change event is triggered by user actions, the handler on the pa...
I am currently setting up the jQuery validation plug-in for use in our project.
By default, there are some events automatically set up for handling. I.e. focus in/out, key up events on all inputs fire validation. I want it to only fire when the submit button is clicked.
This functionality seems to be in-built into the plug-in, which i...
I wrote the following code for a project that I'm working on:
var clicky_tracking = [
['related-searches', 'Related Searches'],
['related-stories', 'Related Stories'],
['more-videos', 'More Videos'],
['web-headlines', 'Publication']
];
for (var x = 0, length_x = clicky_tracking.length; x < length_x; x++) {
links = document.ge...
I've got the following code:
$("ul.relatedAlbums li").hover(function(){
$(this).css({fontWeight:"bold"});
},
function(){
$(this).css({fontWeight:"normal"});
});
I've heard good things about event delegation and speed performance. Using jQuery's delegate method, I imagine it would go something like:
$("ul.relatedAlbums").deleg...
ok i've wracked my brain and others to figure out why this is happening in IE and latest version of FF. It works in chrome. i am but a novice developer and recently started using jquery. so i dont even know if i'm going about this correctly.
its a basic form for the most part. jquery ajax post() then get() to update the page. onc...
Hi all,
I've tried so many different possibilities to achieve what I feel like should be a simple code execution. I am loading DOM objects from the server via .load(). One of the loaded items is an input text box with a date in it. I want to load the jdpicker (a plugin datepicker) when I click on the input box. Due to the behavior of .li...
I'm looking to implement event delegation on blur/focus events, in a similar way to that suggested on quirksmode. As explained in TFA, blur and focus events don't bubble, so you can't use event delegation with them in the bubbling phase, but you can grab them in the capture phase (man, javascript events are weird).
Anyhow, as far as I ...