jquery

How do you create a toggle button?

I want to create a toggle button in html using css. I want it so that when you click on it , it stays pushed in and than when you click it on it again it pops out. If theres no way of doing it just using css. Is there a way to do it using jQuery? ...

How can I post an array of string to ASP.NET MVC Controller without a form?

Hi there, I am creating a small app to teach myself ASP.NET MVC and JQuery, and one of the pages is a list of items in which some can be selected. Then I would like to press a button and send a List (or something equivalent) to my controller containing the ids of the items that were selected, using JQuery's Post function. I managed to ...

Why can't I focus a control that I reveal with slideDown()?

I want to reveal a div with an input inside when you click a button, and set its focus. If I use show(), it works, but if I use slideDown() the focus is lost after the animation completes. How can I prevent this from happening? Sample code: $("document").ready(function(){ $("#MyButton").click(function(e){ e.preventDefault(); ...

jQuery Validation: How to not display errors? OR How to display errors as a tooltip?

I want my errors to float above, left-justified, the input field that doesn't validate. How can I do this? If I can't, how can I turn the errors off? I still want the fields to validate (and highlight on error), but not for the actual error messages to display. I couldn't seem to find anything in the jQuery docs that would let me tur...

How do I catch jQuery $.getJSON (or $.ajax with datatype set to 'jsonp') error when using JSONP?

Is it possible to catch an error when using JSONP with jQuery? I've tried both the $.getJSON and $.ajax methods but neither will catch the 404 error I'm testing. Here is what I've tried (keep in mind that these all work successfully, but I want to handle the case when it fails): jQuery.ajax({ type: "GET", url: handlerURL, da...

Weird Behaviour in jQuery's html method

Any good reason why $("p").html(0) makes all paragraphs empty as opposed to contain the character '0'? Instead of assuming I found a bug in jQuery, it's probably a misunderstanding on my part. ...

jquery/js -- How do I select the parent form based on which submit button is clicked?

Hello! I have a web page with 3 forms on it. Not nested, just one after the other (they are almost identical, just one hidden variable that's different). A user will only fill in one form, and I'd like to validate/etc all the forms with only one JS script. So how, when a user clicks the submit button of form#1, do I make my js script ...

JQuery - replace one string for another in .load-ed html?

I'm loading an html snippet using $("#TemplateDump").load("Themes/default.template", function() { processTemplate() }) The html i am loading contains <div> `hello ##name##, your age is ##age##. your page is <a href="##website##">here</a> </div> I need to replace the ## placeholders with "joe","112" and "www.whatever.com". Is ther...

Custom accordion - using each

Hey, I am trying to create a custom accordion for my page to that display my posts. I have it in list format using HTML and I am trying to create an effect when you click each header to expand to show more information. But I don't want to have say 6 blocks of code for 6 of the <li> elements I have on the page. Is there a way to run it...

Where should a script block with jquery code be placed on an ASP.NET MVC Master Page?

Getting started with jquery and having trouble getting hello world type example going for asp.net mvc. I get a runtime error "object expected" when trying to load a page with this script. A. Where should script tags be placed in a master page? B. What might I be doing wrong? There are definitely "a" elements in my page? <script src="....

jQuery $(document).ready and ASP.NET MVC Partial

I have quite a few partials in my application, and some of them need to do some jQuery goodness at $(document).ready time. The problem is, if I put the $(document).ready directly into a script block for the partial, then this gets overridden if another partial does the same thing. It seems a solution where the various $(document).ready...

UI Useability - Reordering and merging columns

I'm writing a little web-based utility for my brother who needs to merge columns in a CSV file. I know things like this surely exist somewhere, but a large part of this is that is a fun little exercise. Anyways, I'm trying to figure out the best/neatest way to present the part of the UI where he reorders the columns and chooses which co...

Keeps fading in after, mouseover

Hey, I am trying to fade in a on mouseover and fade out on mouseout: $("p.follow").mouseover(function(){ $(this).fadeTo("slow", 1.00); }) $("p.follow").mouseout(function(){ $(this).fadeTo("fast", 0.50); }) If you go to ryancoughlin.com and on the right side, if you go over it you will see what I mean, it is almost as if ...

Displaying different data depending on login status - client side

Hey all, I was just wondering what the best way to do this is and if it could be bypassed. These are my thoughts. I have a bunch of links that when clicked open up a detail panel underneath which displays more information. This is done ajaxy. The thing is however...if the user is not logged in it should take them to the login page and ...

Streaming jquery(JS files) from a CDN (Google)

This one is a case of not doing your homework.:-) Apart from dynamic loading advantage, does it make sense to include a JavaScript library(jQuery in my case ) from a Google server when I can load it from my server as a single file comprised of the 19kb jQuery zip file + the additional JavaScript code I have written – all compressed wi...

Having trouble with rounded corners with jquery that do not round immediately in asp.net mvc app

I am using the rounded corners plugin for jquery and have it working rounding elements in my page. The only issue I have is that the elements appear on the page un-rounded and then round. What do I need to do so that the elements only appear rounded? I originally put my script tags in the head element but should they go somewhere else i...

ASP.NET control in JQuery modal

Ok, I am new to JQuery, I have a modal that has a asp:Literal control in it. The literal is controled by whatever link is clicked to activate the modal. So, I had hoped it would be as easy as giving the literal value onClick of the link but that's not it. I'm hoping: the value of the literal is set on the page load so I have to put it ...

Json or Html? How to tell?

I have a controller that returns either JSON or partial html depending on if the user is logged in. Is there anyway to tell the difference once the result has been returned?? What is the best way. Obviously i have different actions to complete if the response is json or if it is the partial html. With the json one i do a redirect to t...

Add select attribute to Html.DropDownList using JQuery

I have the the following html elements: <tr> <td> <label for="casenumber">Case:</label></td> <td> <%=Html.TextBox("casenumber", "", new Dictionary<string, object> { {"id", "casenumberID"} })%> </td> </tr> <tr> <td><label for="fogbugzUser">Users:</label></td> <td> <%=Html.DropDownList("UserList", (Select...

How do you select a particular option in a SELECT element in jQuery?

If you know the Index, Value or Text. also if you don't have an ID for a direct reference. This, this and this are all helpful answers. Example markup <div class="selDiv"> <select class="opts"> <option selected value="DEFAULT">Default</option> <option value="SEL1">Selection 1</option> <option value="SEL2">Selection 2</option> ...