jquery-event-binding

passing variables to .load(html) in jQuery

Say I have jquery code like this: html += '<div class="index">' + item.index + '</div>'; // many more similar html += statements // load items $('div').append(html); This html is getting too unmanageable, so I'd like to move it to an external file. What's the best way to pass variables to the HTML as i load it? Do i just have to loa...

Unbind click event with jQuery failing.

Hi, I am using a highly modified version of the jqueryFileTree plugin, that is able to add new files and folders. When a new file is created in realtime I have to bind the tree again to the click event so that all new files and folders can work as intended. Just re-binding the filetree has caused me some trouble with the functionality ...

Bind to jQuery event only for particular elements

I am relatively new to jQuery but the below code seems logical but is not working as I would expect. I am utilizing the Colorbox jQuery plugin. My intention is to only add a listener for the 'cbox_closed' event on 'a' elements who have an id that contains 'Remove'. Unfortunately, as presently implemented this adds the listener on all ra...

jQuery children of cloned element not responding to events

Summary I am using jQuery to clone a div ("boxCollection") containing groups ("groupBox") each of which contains a set of inputs. The inputs have change events tied to them at $(document).ready, but the inputs inside the cloned divs do not respond to the event triggers. I can not get this to work in IE7, IE8, or FF3. Here is my sam...

jquery's event.stopImmediatePropagation() doesn't seem to be working

I'm working with some existing javascript code which takes an LI and makes it droppable to an input field. I wanted to add an additional constraint to this, and enforce this by making my own event handler, and calling event.stopImmediatePropagation() if the constraint is not met. This existing javascript is look like this: $input.droppa...

jQuery live doesn't appear to bind click event.

The dynamically added links (classnames .divToggle and .removeDiv) only function if clicked twice the first time. What is preventing them from working properly right away? $(document).ready(function(){ // adds click event to links. $('a.divToggle').live('click', function(event) { // Toggles the visibility of divs. event.preventD...

jquery stop child triggering parent event

Hi, I have a div which I have attached an onclick event to. in this div is a a tag with a link. when i click the link the onclick event from the div is also triggered. how can i disable this so that if the link is clicked on the div onclick is not fired. script. $(document).ready(function(){ $(".header").bind("click", fun...

Registering for jQuery(window).load(...) event, after the event has fired?

Hello, I am new to the group and just had a simple question about the jQuery(window).load(function() {});. I have an external JS file that gets inserted dynamically on the page "after" the window load event occurs. Inside this JS file I have a statement as follows: jQuery(window).load(function() { alert("Something"); }); The que...

HTML Link and Jquery Live Only Works on First Try with one click

Hi Everyone, I'm running into a problem with jquery live event binding on a link. When the link is added to the page it works fine, however when another link is added to the unordered list it requires two clicks for the click event to fire on either link. Any ideas? $("div#website-messages ul li a").live("click", function() { var...

How to call regular JS function with params within jQuery ?

Is there another way to run a regular JS function with params passed than what I use below ? It seems redundant use a on-the-way function to do this. function regularJSfunc(param1,param2) { // do stuff } $(document).ready(function(){ $('#myId').change(function(){ regularJSfunc('data1','data2'); }); } Using a .bind event ...

jQuery: is element.click(func) or element.attr('onlick','func()') more efficient?

I'm populating a list by cloning elements into it. Then I change attrs to make each item unique. They need to call a function on click, so I'm wondering if it's more efficient to use new_element.click(func); or new_element.attr('onlick','func();'); ...

How can I set the order of events in Prototype?

I need to be able to set the order of event handlers for a click event using Prototype. I need to insert an "Are you sure?" pop-up before an Ajax call modifies data. Due to the way the program is structured, I can't change the order of js click bindings. I love jQuery and there's an elegant solution to this problem right here on Stack...

Bind an event handler to multiple elements jQuery?

Hello all. I've done some experimenting, but can't seem to successfully bind one event handler to multiple elements using jQuery. Here's what I've tried: $('selector1', 'selector2').bind('click', function() { $('someSelector').removeClass('coolClass'); }); I've tested all my selectors, and they are all valid. Is what I'm t...

jQuery date picker not persistant after AJAX

So I'm using the jQuery date picker, and it works well. I am using AJAX to go and get some content, obviously when this new content is applied the bind is lost, I learnt about this last week and discovered about the .live() method. But how do I apply that to my date picker? Because this isn't an event therefore .live() won't be able to ...

jQuery event handler queue

Overview of the problem In jQuery, the order in which you bind a handler is the order in which they will be executed if you are binding to the same element. For example: $('#div1').bind('click',function(){ // code runs first }); $('#div1').bind('click',function(){ // code runs second }); But what if I want the 2nd bound code to ru...

jQuery capture all changes to named input on a form

I'm trying to determine when any of a set of named input/select/radio/checked/hidden fields in a form change. In particular, I'd like to capture when any changes are made to fields matching jQuery's selector $("form :input"), and where that input is has a name attribute. However, the form isn't static i.e. some of the fields are dynami...

jQuery click eventhandler issues.

I've build a site that has accordion sections that expand whenever someone clicks on the header section for that page, the click handler is placed on $('.section h2').click However, when a user is logged in as admin, there are 'EDIT' links applied to the header, so I only want the section to expand if the area clicked is not "a.edit-...

How can I correctly register event handlers for jQuery UI Autocomplete (Combobox) for Ajax submission?

I am trying to get an autocomplete working and making an Ajax form submission on change, and so far the first is working but not the second. I am using jQuery UI Autocomplete with Combobox, http://jqueryui.com/demos/autocomplete/#combobox. From my Django template, I define a handler, presently beginning with an alert that seems never to ...

Trigger second function in toggle()

Hi all, Is there a way I can call the second function in toggle(function(){},function(){}) Thanks in advance ...

how to apply event.stopPropagation ?

Hi, Let me explain the problem first. I am using the following UL structure <ul onmouseover="smenu_over(this)" onmouseout="smenu_out(this)" class="sub-menu" style="left:0;"> <li><a href="#">Navigation Item with long text do text wrap</a></li> <li><a href="#">Sub nav item</a></li> <li><a href="#">Sub...