jquery

Handling events of HTML elements inserted by jQuery

I currently have an anchor tag that, when clicked, appends another anchor tag to the DOM. This is all done via jQuery. I know what the "id" attribute of the anchor tag to be added will be. However, when I try the following code, it fails to handle the newly added anchor tag's click event: $("#id").click(function() { alert("test");...

How do I make jQuery modify only one div, instead of all divs of the same class?

Each page of my site has 10 (almost) identical divs, varying only in the text within. When a certain part of a div is clicked, I want a different part of that div to be modified. I'm using this code: $(document).ready(function(){ $(".notLogged img").mouseover(function(){ $(this).parent()>$("span").html("You must be logged in to vote...

Use Jquery Selectors on $.AJAX loaded HTML?

I have $.ajax({ url: identity, success: function(data) { ProcessIdentityServer(data) } }); When 'data' is returned, is there a way to run selectors against it without adding it into the DOM. So for example, how can I get all the href values of any LINK tags contained in the HTML held in 'data' without adding it to the DOM first? S...

Adding some custom session variables to a JavaScript object

I currently have a custom session handler class which simply builds on php's session functionality (and ties in some mySQL tables). I have a wide variety of session variables that best suits my application (primarily kept on the server side). Although I am also using jQuery to improve the usability of the front-end, and I was wondering ...

How would I do a proper fadein for dynamic content refreshing with jquery?

I have a .txt file that I need to include into a page, that gets dynamically updated every 5 seconds, so I need to refresh it via ajax, so that the updated content can be seen without refreshing the page. I want to do it so it fades into the div, with every 5 second update. Currently Im doing it like this, which is pretty ugly looking ...

jQuery: is val() fast enough to use repeatedly or is it better to put the value in a variable

If you are doing something like the following: var i = $('input[@name=some_field]'); if (i.val() != '' && !(i.val() >=1 && i.val() <= 36) || i.val() == 'OT')) { i.focus(); } is i.val() fast enough to use it multiple times or should you do: var value = i.val(); first and then use value in the if statement, like: var i = $('inp...

How to get the current URL in jQuery?

I am using jQuery. I'd like to get the path of the current URL and assign it to a variable. Example URL: http://localhost/menuname.de?foo=bar&amp;amp;number=0" ...

validation in text boxes using datepicker

I have three textboxes, box1-filled by user1 box2-filled by user2 box3-filled by user3 I have also a default value for these three boxes. 1.Now when box1 is selected user1 cannot input dates before the default date and it should not be allowed to select dates more than in box2(if not blank,otherwise default date is considered). 2.user2 ...

jquery: on click, add text from title-tag to an input box

I have a contactbook, and a form close to it... For the form, one of the requirements is to fill in the receiver for the message. So when the user clicks on a contact from the contactbook, automaticly the username from the titel-tag should appear in the receiver inpunt in the form. All help with this is appreciated!! ...

Jquery Load question

I want to load content via the jquery load function however inside the page that is loaded i have other links which I want to load over the top of the previously loaded content. see the link below for a simple example of what I am trying to achieve but it does not work however. Any pointers/tips would be amazing. cheers http://pastebi...

AJAX - Reload a part of a webpage without the use of a separate file to load

Title might be a bit confusing, so let me explain. I have a website that has a side-panel, which contains information about the user, things the user can do, etc. When the user is not logged in, this side-panel becomes the area for logging in or registration. The code for this is: <?php if($user->loggedIn) { ?> <!-- side-panel for log...

How do you handle errors from AJAX calls?

Let's say I have the following jQuery AJAX call: $.ajax({ type: "POST", url: "MyUrl", data: "val1=test", success: function(result){ // Do stuff } }); Now, when this AJAX call is made I want the server-side code to run through a few error handling checks (e.g. is the user still logged in, do they have permission...

How do you trigger the "error" callback in a jQuery AJAX call using ASP.NET MVC?

This is related to my question on how to handle errors from jQuery AJAX calls. Several responses suggested that I use the "error" callback to display any errors from a jQuery AJAX call. I was wondering how to do that using ASP.NET MVC. Is there a way for my controller action to return an error that would be accessible from the "error"...

Dojo to jQuery migration

I have this code: dojo.declare("City", null, { constructor : function(cityid, cityinfo){ } }); dojo.declare("TPolyline", GPolyline, { constructor : function(points, color){ }, initialize : function(map){ }); What should be it's jQuery equivalent? ...

How to make this jQuery function more elegant?

On my page I have a drop-down select box, with a default value of (empty). When the user selects an entry, the appropriate form for that entry type is displayed. Couple of problems.. The code is not DRY and seems more verbose than it needs to be, so not easily maintainable / extensible. When a user selects something, fills in the form...

jQuery selection with dynamic id's.

I have a form that is dynamically generated, and has dynamically generated id's (and potentially classes). The forms are the same but they have the related id tacked on to the end. How can I select each set of inputs and apply code to each one? I was experimenting with $('input[id^=@id_airline_for_]') but could not get it to fly. I sus...

the example uses RoR ajax protoype helpers - How to do this in JQuery instead?

This page show how to do depended drop-downs using RoR+Prototype. Wonder if somebody would show how to do in JQuery insteaad http://pullmonkey.com/2008/3/30/dynamic-select-boxes-ruby-on-rails ...

change width more than 32767 with jquery

I want to make a mini timeline with jquery and this timeline have width more than 32767 px. When I change it by jquery $(".timelinecontainer").width(32767); in Opera does not change it, but in others browsers it works. What can you give me advices ? Sorry for my English :) ...

Javascript order of execution - How come it does this?

I am quite on lost on why Javascript does certain things in this way, or maybe I coded something wrong. But how come the code after $.getJSON gets executed before the callback is complete? window.ratingCallback = function(data){ if(data[0].code == 3){ ratingHTML = buildHTML(0); console.log('a'+ratingHTML); ...

jquery & php: saving some data without reload

I have three buttons and need to save some data. I have a idea, I have to set an ID to every button and then let the JS determinate witch button that has been pressed, like: $("#mySpecifikButton").click(function() { ....some code here... }); but then Im stuck. For example I have 9 users. All they have an ID in the db. So now we have a...