jquery

Javascript/JQuery: return immediately from PARENT function in call to each() via anon function

For example: > function foo() { > jQuery(whatever).each( function() { return; // this just exits the anonymous function - is there a way to return from foo? } ); > > } ...

Jquery .show() to display div tag

I am using this code to display a grid $('#table1 tr').bind('click', shows); function shows() { $('#table').show(); } Where #table is the following HTML fragment: <div id="table"> <p>shiva</p> </div> I am not able to show shiva? is this right what I am doing here? thanks ...

Include OpenX ad in a jquery-ui dialog?

I'm loading some content into a jquery-ui dialog via .ajax. That's all working fine but now I've been given an OpenX ad to embed into the dialog & can't figure out how to do it. I know all the script is stripped when coming in via ajax, & I know how to use $.getScript to load .js files for use in the dialog, but the OpenX ad script I'v...

Chrome 5 problem with scroll

$(document).keydown(function (event) { if(event.keyCode==38 || event.keyCode==40) { var row; if(event.keyCode==40) row=$(row_selected).next(); if(event.keyCode==38) row=$(row_selected).prev(); if(row.length==0) { row=$(row_selected); } row_select( row ); ...

Problem with multiple jQuery UI dialogs and hyperlinks

I'm having a problem similar to the one here: Prior jQuery UI Dialogs become nonresponsive.... Here's how the problem happens: If I open one dialog and then a second dialog, and then close the second dialog, hyperlinks in the first dialog no longer work. Here is the code for the dialogs: <script type="text/javascript"> $(function(...

Script Debugging in IE

Hi Folks, I'm really interested which way you guys use to effectivly debug a large (let's say 1000 lines and more) javascript in IE7/8/9. I'm so sick of reading a message like 'error in line 9328789237498" or "line 1" which totally makes no sense. No error description. There must be something like Firebug? please? :) Kind Regards --...

Is there a sexier way to write this jQuery selector?

I want to select all the children of the body element before element with id foo (which is a child of body). Since it doesn't look like there are :before() or :after() selectors, I've got it working like this: $('body > :first').nextUntil('#foo').andSelf(); but it seems kludgy. Could this be done with fewer function calls, or more eff...

Fancybox force scroll to top

I'm using the jQuery Fancybox plugin to display some content on a website. Unfortunately, when a link is clicked, the lightbox that is loaded starts at the same scroll position as the previous one. I tried using self.scrollTo(0,0) $.scrollTo(0) $('#top').scrollTo(); and a few others methods to push it back to the top, but ...

What would be the best way to dynamically add a set of rows to a table using JQuery?

I have a following table using MVC that shows number of items the user has. <table border = "1" id="tblItems"> <% var itemnum = 1; foreach (var item in Model.Items) {%> <tr> <td colspan="2" bgcolor="Silver"><strong>Item#<%=itemnum%></strong></t...

jquery click event not working on first click,

$("#table").click(function(e) { var row = jQuery(e.target || e.srcElement).parent(); $('#table tr').bind('click', show); name= row.attr("id"); }); I am not getting the id value very first time i click on the row? second time I am getting fine? can anyone tell me why its happen...

How do I retrieve the zero-based index of the selected option in a select box?

Let's say I have the following in my HTML code: <select name="Currency" id="Currency"> <option value="0.85">Euro</option> <option value="110.33">Japanese Yen</option> <option value="1.2">Canadian Dollars</option> </select> Using jQuery, I can use $("#Currency").val() to give me the selectd value, and I can use $("#Curr...

Returning two or more values from a function

I need to return multiple values from a ColdFusion function in an ajax callback function. Here's what I've got: $('input[name="StateName"]').live('change', function() { var StateID = $(this).parents('tr').attr('id'); var StateName = $(this).val(); $.ajax({ url: 'Remote/State.cfc' ,type: "POST" ,data:...

JQuery Help: toggle() is not working properly

Hi All, I'm trying to use JQuery toggle functionality, but not able to use properly. Instead of smooth slide up and down, it goes very fast and not in an animated manner. I want to achieve sliding effect in my code, like this has (Please see Website Design, Redesign Services slider): Here is my code: HTML: <div> <div class="j...

AJAX server calls on a JSF-centric app

I'm building a JSF 2 application. I wanted to integrate it with jQuery, e.g.: $.getJSON(contextPath + '/something', function(data) { // ... }); I need contextPath/something to return data in JSON. How can I do it? I know I can assign another servlet to this URL, but this approach does not seem to scale well. One could use a more scal...

JQuery Tool tips

I want to create a tool tip for an image with a link now I had it working one but it doesn't work with the 2nd image. Here is my Sample Code: <!-- trigger element. a regular workable link --> <a id="test" title="Name - Title">Name</a> <!-- tooltip element --> <div class="tooltip"> <div><span class="name">Name</span><br /> Title <...

How can I debug why this click handler never fires?

I am going to be excrutiatingly detailed here. I am using Firefox 3.6.3 on Max OSX with Firebug 1.5.3. I have two versions of a project, one which works and one with a bug. One I downloaded and one I typed by hand. Take a guess which one doesn't work. They should be the same except that mine uses a newer version of jQuery and the ...

jQuery HOW TO?? pass additional parameters to success callback for $.ajax call ?

Hello jQuery Ninjas! I am trying, in vain it seems, to be able to pass additional parameters back to the success callback method that I have created for a successful ajax call. A little background. I have a page with a number of dynamically created textbox / selectbox pairs. Each pair having a dynamically assigned unique name such as...

JSON from jQuery to PHP

I need to pass a JSON object from $.post() jQuery function to PHP page. I tried this plugin jquery-json, but don't work: //include jquery.js and jquery.json.js $(document).ready(function(){ var data = new Object(); data.hello = "Hello"; data.world = "World"; var datajson = $.toJSON(data); $.post('file.php', {data: d...

how do I disable options based on the previous selection?

I have three drop-down menus for each sample shirt; product, colour and grade. Not all products are available in all colours and/or grades. I would like to disable the options that are not available based on the users selection. I've tried using this answer here (using a radio select). Unfortunately, I can't get it to work with an opt...

Jquery to max number from a set of divs

Guys, Given the following HTML <div class"myclass">10</div> <div class"myclass">25</div> <div class"myclass">50</div> <div class"myclass">20</div> I want Jquery to return the maximum value found on divs with class:"myclass". (This is 50) I thought of using .find.text() will be a good starting point but cant figure out exactly how, ...