jquery

How can I refactor this jQuery code?

The code below is for a simple newsletter signup widget. I'm sure there's a way to make it more concise, any ideas? var email_form = $('.widget_subscribe form'); var email_submit = $('.widget_subscribe .submit'); var email_link = $('.widget_subscribe .email'); // Hide the email entry form when the page loads email_form.hide(); // Sh...

How to update value of a radio using Jquery

I have this HTML code for radios: <input type='radio' name='a_27' value='Yes' id='a_27_0' /> <input type='radio' name='a_27' value='No' id='a_27_1' /> I'm trying to set the selected value of the radio using this code: var field="a_" + this.id; $('[name="' + field + '"]').val(this.value); console.log("name is " + field + ", val is " ...

How to remove all Click event handlers in Jquery

I'm having a problem. Basically, when a user clicks an 'Edit' link on a page, the following Jquery code runs: $("#saveBtn").click( function() { saveQuestion(id); } ); By doing this, the onClick event of the save button calls the saveQuestion() method and p...

Accessing $(this) within a callback function

I'm working on changing prompt() to jPrompt() since IE blocks prompt() from running. The problem is $(this) no longer works correctly because jPrompt() doesn't return a value, but uses a callback function. So lets say I have something like this, which works: $("a.foo").click(function(){ $(this).text(prompt("Type Something","")); }...

Control link preferences with radio button controls and jquery

For any links with a particular CSS class, I'd like to control whether the links open in the same window, a new window or a pop-up (using onclick), based on the user's selection from a group of radio buttons -- and then save that choice in a cookie (all using jQuery). Anyone know how to accomplish this? ...

Headaches with radios in Jquery

I have 2 radios: <input id="a_15_0" type="radio" value="abc" name="a_15"/> <input id="a_15_1" type="radio" value="xyz" name="a_15"/> Both are unselected. I have only the name of the radio, i.e a_15, but not the IDs. 1) How can I get the value of the selected option of this radio? E.g if the user clicked 'xyz', how can I get it? Right...

How to parse a variable in Javascript

I'm trying to use this code: var field="myField"; vals[x]=document.myForm.field.value; In the html code I have <form name="myForm"> <input type='radio' name='myField' value='123' /> 123 <input type='radio' name='myField' value='xyz' /> xyz </form> But this gives me the error: document.myForm.field is undefined How can I get ...

Problem adding image overlay (jQuery)

What I want to do is find all images with a particular class name, and place an overlay image over them. My script thus far in jQuery 1.2.6: jQuery.noConflict(); jQuery(document).ready( function($) { var module = $(".module-contactus div div div"); module.find("img.let").each( function() { var iWidth = $(this).width(); var i...

How to select all textareas and textboxes using jQuery?

How can I select all textboxes and textareas, e.g: <input type='text' /> and <textarea></textarea> on a page and have the property style.width="90%"; applied to them? ...

jquery tablesorter with accounting number format

I'm using jquery tablesorter and I'm trying to sort a column with values similar to this: $100,000 $38,000 ($4,000) $2,000 Data within () are negative numbers. When using the default sort feature, it does not recognize the ($4,000) as a negative number, so I'm trying to create a custom function to handle this. The solution below ...

JQuery - How to get at all the data

I have a paging menu PartialView in my MVC app that looks like: <% if (Model.TotalPages > 5) { int index = Model.PageIndex; int minIndex = index - 2; int maxIndex = index + 2; if (index < 2) { minIndex = 0; maxIndex = 4; } if (index > Model.Tot...

Site renders differently in CFM vs HTML on Chrome

Ok, so this is very odd. I have a site that I am breaking out into several ColdFusion documents for header/footer/etc. The footer of my site is affixed to the bottom using a jQuery plugin. When I go to the index.cfm page (in chrome) to view the results, the footer placement is off. I then "right-click...view source" and highlight all...

How can I refresh a ASP.NET MVC UserControl with jQuery?

Hi everyone! I have a UserControl that binds directly to database, that is, it's not rendered by any Action. It works independly. But, from times to times I have to refresh it to get new information from database. I've already worked with refreshing UserControls in jQuery via Ajax, but in all of these cases, I had a Action to make the ...

Table Header manipulation

Hello, I'm using this in conjunction with the tablesorter plug-in, my goal is to have a blank class attribute in any column that is not being sorted, i.e. when I click one column the class attributes in the others are removed. I have a table with a whole bunch of headers, basically what I want to be able to do is when I click on a table...

JavaScript: changing the value of onclick with or without jQuery

I'd like to change the value of the onclick attribute on an anchor. I want to set it to a new string that contains JavaScript. (That string is provided to the client-side JavaScript code by the server, and it can contains whatever you can put in the onclick attribute in HTML.) Here are a few things I tried: Using jQuery attr("onclick",...

How to autocomplete in ASPX with original page request only?

We are developing an ASPX (.NET 2.0) page that includes a select list with far too many elements in it (200+). We need some form of autocomplete to make this into something that behaves like a text box, but with autocompelte suggestions. We would like to use JQuery. So far our searching has only turned up autocompletes that require som...

jquery.ui sortable issue

Hello, I have created a nested list with drag/drop functionality. My issue is that I want each nesting to sort in itself. For example: -first_level -first_level -second_level -second_level -first_level "First level" should not be able to go into "Second Level" and vice versa. I thought I could do this with the containment option...

submit button does not trigger server-side code

the question says it all. i've an asp.net page using jquery. at first when i clicked the submit button, it'd show the object expected error. i ran the firebug and it displayed the error of 'return validate()' function which was added onClientClick of the button. <script type="text/javascript"> $(document).ready(function() { ...

jQuery mulitple click handlers..how to ensure order of firing?

I have 2 click handlers binded to an element like so: in the file which contains the control I am binding to, I have the first handler, which does some functionality specific to that control $("#mycontrol").live("click", function() { alert("foo"); }); In the main page which uses that control, I have another handler binding to that el...

jQuery Autocomplete losing text on AutoPostBack

I have a jQuery Autocomplete field on an ASP.Net Webform and everything has been working great until now. I also have a DropDownList that I have a need to fire onSelectedIndexChanged with AutoPostBack. When I changed my code to do the AutoPostBack, the text field that has the jQuery AutoComplete on it comes back blank. However, if I lo...