jquery

jQuery: Cannot change style of element after selected

Here is my code. Where you see "alert([...]);", an alert pops up. Why doesn't the CSS style change? The 'click' event doesn't fire either! resolveSideMenuAddress: function () { var firstLink = $("#masterHeaderMenu .masterHeaderMenuButton a:first"); function select(link) { alert('i alert'); link.css({ ...

Fixed mouse pointer with jQuery draggable

I'm building a little game in HTML5. The canvas element is a viewport into the game world. The user can move the viewport's position in the world by clicking and dragging with the mouse on a small icon. The problem is that the scrolling stops when the mouse pointer hits the edge of the screen. In all likelihood, that will limit scrol...

jQuery $.data(): Possible misuse?

Perhaps I'm using $.data incorrectly. Assigning the data: var course_li = sprintf('<li class="draggable course">%s</li>', course["fields"]["name"]); $(course_li).data('pk', course['pk']); alert(course['pk']); // shows a correct value alert($(course_li).data('pk')); // shows null. curious... course_li is later appended to the DOM. ...

Jquery UI Autocomplete widget conflict qith jqeury.menu widget - how can I solve it?

My app already has a completed menu using jquery.menu.js found at http://wiki.jqueryui.com/Menu. I'm now also trying to add the jquery autocomplete widget from jquery ui 1.8.1 - but both of these have a .menu() function that conflicts with each other. If I put jquery-ui-1.8.1.custom.js first in the head, then autocomplete works but the...

Customising event delegates in the jQuery validation plug-in

I am currently setting up the jQuery validation plug-in for use in our project. By default, there are some events automatically set up for handling. I.e. focus in/out, key up events on all inputs fire validation. I want it to only fire when the submit button is clicked. This functionality seems to be in-built into the plug-in, which i...

jQuery Validate - resetForm() Not Behaving as Expected

Site in question is http://epraxadev.com/kw/palisade-palms/ "Click here for brochure" and "Learn More about Palisade Palms" both bring up a lightbox with the same HTML form to be filled out...the "learn more..." link also changes some of the HTML in the form (the value for a hidden form field, and the fields required). I'm using Colorb...

Hiding <option>s in IE

I wrote this nifty function to filter select boxes when their value is changed... $.fn.cascade = function() { var opts = this.children('option'); var rel = this.attr('rel'); $('[name='+rel+']').change(function() { var val = $(this).val(); var disp = opts.filter('[rel='+val+']'); opts.filter(':visible'...

What would be jQuery equivalent of this sf hover suckerfish code?

What would be jQuery equivalent of this sf hover suckerfish code? <script> sfHover = function() { var sfEls = document.getElementById("navbar").getElementsByTagName("li"); for (var i=0; i<sfEls.length; i++) { sfEls[i].onmouseover=function() { this.className+=" hover"; } sfEls[i].onmouseout=function() { ...

How to bind to javascript events after the DOM changes

I have a function that binds to a tr tag to provide a mouseover effect like this: $(".grid tr").bind("mouseenter", function () { $(this).addClass("hover"); }).bind("mouseleave", function () { $(this).removeClass("hover"); }); The problem is the grid is loaded via ajax when paging occurs, or filtering etc. This causes the gr...

Drag and drop: jQuery UI or Scriptaculous?

Dear all, I am in the middle of the road whether to use jQuery UI or Scriptaculous for drag and drop. I am using Ruby on Rails, and Scriptaculous support in Ruby on Rails is superb with the existence of scriptaculous_helper.rb. But I have already use jQuery for the ajax and DOM manipulation. I do not mind to use scriptaculous since we c...

$.each() iterating over characters in a string - do I need to eval()?

I have json data being returned as a collection: var foo = ["6", "7", "33"] using JSONP in jQuery. Since I'm using JSONP, the data is being returned to a callback function, which is interpreting it as a string instead of a collection. Do I need to run eval(foo) on the string in the callback before handling it as a collection, or is ...

jQuery: Setting 'style' attribute of element with object

I saw this in our codebase the other day: link.attr('style', map({ color: '#9a4d9e', cursor: 'default' })); map is defined as: function map(map) { var cssValue = []; for (var o in map) { cssValue.push(o + ':' + map[o] + ';') } return cssValue.join(';');...

jQuery: How do you preload sound?

I have a website that plays sound when you click a button. This is how I do it function PlaySound(soundfile) { $('#soundContainer').html("<embed src='/uploads/sounds/" + soundfile + "' hidden=true autostart=true loop=false>"); } How do you preload the sound file beforehand? Thank you. ...

How and what benefit i can take from included Sizzle.js along with jquery 1.4.2?

latest jquery 1.4.2 downloaded from jquery.com comes with Sizzle.js also. How and what benefit i can take from included Sizzle.js? Is Sizzle.js a standalone library? Why it's included inside jquery library, for what purpose? /*! * jQuery JavaScript Library v1.4.2 * http://jquery.com/ * * Copyright 2010, John Resig * Dual licens...

Can I use jQuery ajax in a SharePoint WebPart without having to worry about the same origin policy?

My current project for work involves developing a SharePoint 2007 WebPart which will be deployed by our clients. To provide a better user experience, I am "simulating" ajax via setting the SRC attribute of an IFRAME to be the address of an HTTP handler. These handlers are deployed to the layouts directory in the 12 hive. Although this w...

jQuery sibling selector?

Hi, I have a table which I'm trying to do a pricing list, that auto-computes the tax component.. I'm getting the value from price_1, applying a math cal, and saving it to tax_1. I could read the number of the end of the id, but hopefully there is a cleaner way with jQuery. E.g. I would have a lot of fields like.. price_1 price_2 ...

Simplify my menu animation code

I've got a bunch of 'project' divs that I want to expand when they're clicked on. If there's already a project open, I want to hide it before I slide out the new one. I also want to stop clicks on an already open project from closing and then opening it again. Here's an example of what I mean (warning - wrote the code in the browser): ...

Calling a Function Based on a String Which Contains the Function Name

var foo1,foo2; switch (fn) { case "fade" : foo1 = "fadeOut"; foo2 = "fadeIn"; break; case "slide" : foo1 = "slideUp"; foo2 = "slideDown"; break; } eval("$('.cls1')." + foo1 + "();"); currentSlideIndex = currentSlideIndex + n; eval("$('.cls1')." + foo2 + "();"); Any better way to achieve this without using eva...

whether this is a valid getJSON() in jquery?

I am using asp.net mvc with jquery... I have made a json call to a controller method and it returns json object [Object object] for me. I dont want that instead i want to get the json string... Any suggestion... $(document).ready(function() { $.getJSON('Materials/GetMaterials', null, function(data) { alert(data); ...

Jquery :not selector not working in ie

I have the following html code: <ul> <li class="O"> <label for="radio1">Radio 1:</label> <input type="radio" name="radio1" value="Yes" checked>Yes</input> <input type="radio" name="radio1" value="No">No</input> </li> <li class="O"...