jquery-events

jQuery $(document).ready(): are multiple bindings to the document load event allowed?

does jquery support multiples of $(document).ready(function() {}); ie. can i make a few of these on the same page and they will all be executed? or does the newest one overwrite the last? ...

jQuery: change function not being induced?

i have the following jquery code: $(document).ready(function() { $('.restrictiveOptions input[type!=checkbox], .restrictiveOptions select').change(function() { // check off enabled for that row if anything changed $(this).closest('.fieldRow').find('.restrictiveOptionEnabled').attr('checked','t...

What jQuery event/method can I use to bind on a dynamic button before click?

I'm trying to attach a jQuery plugin to a dynamically generated button. I've tried the following with no success: $('.myButton').live('click', function() { $(this).file().choose(function(e, input) { // ... }); }); I guess this doesn't work as the plugin needs binding before click. So I tried... $('.myButton').load(fu...

jQuery .append() and script behavior and management

According to the discussion comments here: http://api.jquery.com/append/ the .append() of a script evaluates the script, then discards it. IF the script adds jQuery behavior such as for example: $('#mything').click().addClass('hasclass'); is that event management retained (espcially if complex chaining gets added), or discarded, and...

Why aren't these two bits of JavaScript equivalent?

in jquery 1.4.2, ff 3.6.6: The following code produces three divs, which write messages to the firebug console as you would expect. However, if you uncomment out the loop and comment out the 3 lines doing it manually, it doesn't work - mousing over any of the divs results in "three" being written to the console. Why are these two me...

JQuery Change Event for InnerHTML

In my case i'm writing a Chrome Extension, I don't have access to the other JS that is happening on the page. So I need to make sure that whenever certain elements update their content I rerun a function from the extension. Basically a Change event that can be triggered from innerHTML changing. ...

jQuery's ready queue $(foo) and $(bar) will run in sequence or run in parallel?

If there are 2 or 3 or 20 statements using jQuery's $(function() { ... }) to add functions to be executed when the DOM is ready, will all those functions run in parallel or run in sequence? ...

jQuery Event Bubbling, live(), click event not propogating.

I have two containers, one that isn't generated until the page has loaded. The one generated last (<div class=last></div>) should appear over the first one. Visually it does cover up the first one. However, I cannot get the ".last" to respond to a live() click event. It will respond to the first div, but not the last div (again, the div ...

What's the best way to attach Javascript events to a list of AJAX-loaded search results?

I have a search page that loads results. Each row has a 'Delete' button next to it which I want to fire a particular Javascript function on my page using some parameters specific to that row. Is it best to put the function call directly into the HTML being generated, e.g. onclick="deleteFunc(<params from results array>);" or should I i...

jQuery function used as event handler and for initialization

I'm doing this over and over, and I'm not sure if it is the best way to do so in JavaScript/jQuery. I have a function that acts as an event handler, but also I need to call it on page initialization. Thus I have been using the following code: <script type="text/javascript"> $(function() { function doToggle() { $(...

jQuery .focus() and .blur() not working in Chrome or Safari

I am creating a survey form that needs to have each question and set of answers highlighted (by changing the background color) when the user focuses on them. .focus() and .blur() both work in Firefox and IE, but not entirely in Safari and Chrome. I also tried .focusin() and .focusout() with the same results. EDIT: Clicking does not fir...

JQuery .bind and .Trigger question

Hi – I am using MVC 2 and JQuery with JQModal to create forms dynamically and am having an issue with closing a Modal window that is opened on top of another modal window using Jquery .trigger and .bind to catch the event triggered. The associations for example are: Companies -> address / contacts/ communication ( selectable from...

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 a keypress/keydown/keyup event in JS/jQuery?

Hello all, What is the best way to simulate a user entering text in a text input box in JS and/or jQuery? I dont want to actually put text in the input box, I just want to trigger all the event handlers that would normally get triggered by a user typing info into a input box. This means focus, keydown, keypress, keyup, and blur. I thin...

Trigger second function in toggle()

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

Using the <a> tag as a button without following its link

I use the <a> tag to build buttons. I use JavaScript (jQuery) to implement the behavior. How can I prevent the browser from following a link, while continuing to execute all click() events? This: $("a.button").live("click", function(event) { return false; }); doesn't work, because, depending on the position of that handler it might ...

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...

Problem creating jQuery plugin with textareas

I'm trying to modify this script that emulates the Word 2007 minibar in a textarea. I have wrapped it in a plugin, the problem is that it will not work with multiple textareas. You can try it out at JSBin (Just select som text in the first textarea and then click on the "b") Can someone help me? I'm kinda lost. Update Should have m...

I need to perform an action based on which radio button is selected (by jQuery), but neither jQuery's click or change method is doing what I want

In the callback of a HttpRequest I have, I run this jQuery code: $("input[value='"+data.notetype+"']").click(); So the radio button with the value of data.notetype is selected. This works fine. But I need to perform an action based on what button is now selected. If I use the change() method like this $("input[name='note_type']").ch...

JQuery cleaning up eventhandlers

I'm an actionscript developer getting into jquery/javascript development. I have a question regarding event handlers and binding/unbinding. Say for instance that I have for an div with a img element with an onerror event handler in it. If i replace that that div with a new one do i need to remove the eventhandler bound to the img elemen...