jquery

jQuery to find all previous elements that match an expression

Using jQuery, how do you match elements that are prior to the current element in the DOM tree? Using prevAll() only matches previous siblings. eg: <table> <tr> <td class="findme">find this one</td> </tr> <tr> <td><a href="#" class="myLinks">find the previous .findme</a></td> </tr> <tr> <td cl...

jQuery $.ajaxSend() settings.data is null

I found strange bug (maybe). When I send parameters to $.ajax in a form of hash, and tried to check that params in $.ajaxSend, I found that settings.data is null, settings.url was normal with parameters included. Then I look inside jQuery code, and found that data erased. // If data is available, append data to url for get requests if...

How to combine two jQuery results

How do you combine two jQuery search results? eg: var $allFoos = $('.foo'), $allBars = $('.bar') $allFoosAndBars = $allFoos + $allBars ; Obviously, I just made up that last line, but I hope it makes it sorta clear what I mean. To be clear, the example is greatly simplified, and it could be any arbitrary sets i'm talking about,...

Need help refactoring a simple jquery animation script

Hi I have a status message box (div box) positioned at the bottom of a web page using position: fixed; and bottom: 0;. Its height is initially 11px. I want to allow users to double click it when there are more status messages than what can fit within the default hight, make it grow. If they double click it again or move the mouse away ...

When to prefer JSON over XML?

My requirement is just to display a set of values retrieved from database on a spread. I am using jquery. ...

Convert a jQuery set into HTML

Given a jQuery result set, how do you convert that back into plain HTML? <div class="abc"> foo <strong>FOO</strong> </div> <div class="def"> bar </div> -- var $mySet = $('div'); Given $mySet, how would you go about returning to the plain HTML above? ...

How to bind a click event on a recently added <a> tag in jquery

Hello. I have 6 links on a page to an mp3. The plugin I installed replaces those links with a swf and plays that mp3 inline. The problem I had was that it was possible to activate all 6 links and have all audio playing at once. I solved that problem (I feel in a clumsy novice way though) by catching the < a > tag before it was replaced...

Again a jquery doubt...

I am calling a .txt file from a jquery ajax call, it has some special characters like "±". this ± is delimiter for a set of array...data i want to split it out and push into a js array. but it is not treated as ± symbol when interpreted like this. so how do i get that data as just like browser content? ...

jQuery AJAX - made browser request new location in redirect header

Can jQuery ajax made browser request a new location in redirect header send by server? ...

Navigation, background swap not having every <li> on mouseover

Hey, I am using the following jquery code: $("#top ul li.corner").mouseover(function(){ $("span.left-corner").addClass("left-corner-hover"); $("span.right-corner").addClass("right-corner-hover"); $("span.content").addClass("content-hover"); }).mouseout(function(){ $("span.left-corner").removeClass("left-corner-hover"); ...

What is the most efficient way to create HTML elements using jQuery?

Hi guys, Recently I've been doing a lot of modal window pop ups and what not, for which I used jQuery. The method that I used to create the new elements on the page has overwhelmingly been along the lines of: $("<div></div>"); However, I'm getting the niggling feeling that this isn't the best or the most efficient method of doing th...

Best way to display data via JSON using jQuery

Hey, i am trying to find the best way to display results on my page via an Ajax call using jQuery, do you think the best way is to pass it as JSON or plain text? I have worked with ajax calls before, but not sure which is preferred over the other and for the JSON version what is the best way to read from a JSON file generated by a PHP p...

Ajax based Dashboard On LargeData (Asp.net)

hello guys iam working on some sort of crm application which has huge sales data with all the customer leads etc (ASP.net 2.0/AJAx) i want to create a dashboard which will have four separate data containers each container will have different sort of data and each container has to update it self after some configred time interval . so ...

Method for displaying "loading" message

I am using jquery and the getJSON method and I am wondering if there is a way to display a message saying loading before it loads my content. i know with the jquery ajax calls there is the before submit callbacks where you can have something but the getJSON only has like three options. Any ideas? Thanks, Ryan ...

Using fadein and append

I am loading JSON data to my page and using appendTo() but I am trying to fade in my results, any ideas? $("#posts").fadeIn(); $(content).appendTo("#posts"); I saw that there is a difference between append and appendTo, on the documents. I tried this as well: $("#posts").append(content).fadeIn(); I got it, the above did the trick!...

How to do JavaScript object introspection?

What to do when after all probing, a reportedly valid object return 'undefined' for any attribute probed? I use jQuery, $('selector').mouseover(function() { }); Everything returns 'undefined' for $(this) inside the function scope. The selector is a 'area' for a map tag and I'm looking for its parent attributes. ...

jQuery Autocomplete: Determining if entered text is not a match

I've got jQuery Autocomplete (UI 1.6rc2) up and running fine and when the user picks an item, it updates a hidden form value with the associated ID. How do I set the hidden form value to '0' when the text entered does not match a result from the autocomplete list? In this case, I'll be creating a new entry. ...

Always use jquery selectors or cache them in variables?

jQuery selectors are wonderful, but I sometimes I find myself typing them over and over, and it gets a little annoying. $('#mybutton').click(function() { $('#message-box').doSomething(); $('#message-box').doSomethingElse(); $('#message-box').attr('something', 'something'); }); So often I like to cache my objects in varia...

Issues with jQuery and TinyMCE rich text editor?

I'm experimenting with the Tiny MCE editor. We also use jQuery, and I noticed that the standard Tiny MCE install includes a file called tiny_mce_jquery.js. Can anyone enlighten me as to what that's for? Oddly, I can't find anything about it online. Should I reference it in addition to the standard Tiny MCE script, or instead of? Does it ...

submit form when elements change

In jQuery, if I assign class=auto_submit_form to a form, it will be submitted whenever any element is changed, with the following code: /* automatically submit if any element in the form changes */ $(function() { $(".auto_submit_form").change(function() { this.submit(); }); }); However, if I want to the form to submit only whe...