jquery

jquery - best way of finding if select box option is unselected

Whats the best way to check a select box to find out if the selected options value is empty? i have tried the following and other variations but no luck so far: if($('.mySelectBox').val('').length) { alert('not selected'); } ...

How to gzip ajax requests with Struts 2?

How to gzip an ajax response with Struts2? I tried to create a filter but it didn't work. At client-side I'm using jQuery and the ajax response I'm expecting is in json. This is the code I used on server: ByteArrayOutputStream out = new ByteArrayOutputStream(); GZIPOutputStream gz = new GZIPOutputStream(out); gz.write(json....

JsTree remove and create folder?

Anyone out there who's knows the JsTree jQuery plugin well? I have implemented it and got it working ok for most basic functionality, but now I want to be able to use the functionality for removing and creating new folders. I can't find information about how to do this in the documentation. Here's how I use it right now: $("#divLe...

binding jquery ui methods after ajax calls

I am using jquery ui in several places to create ui elements like tabs, tooltips etc. These all follow the same format of $('selector').ui_method_name, where the ui-method-name could be tabs, accordion, tooltip etc. This all works fine when the page loads first and this line is called on $(document).ready, but in some cases I load conte...

Cache Jquery UI autocomplete Combobox

Hello, I'm using the Jquery UI autocomplete on an existing project. Well, the performance is dog slow, especially when executing the input.autocomplete("search", ""); My solution was to cache the information, so even though its dog slow it only occurs once. I think I'm missing a very simple Javascript bug and I would really apprec...

how to control selecttouislider control programmatically?

a question regarding the programmatic control of the SelectToUISlider: 'http://www.filamentgroup.com/lab/update_jquery_ui_slider_from_a_select_element_now_with_aria_support/' I want to have a play/pause button control this specialized jquery slider widget. normal use seems for the user to slide the control, but I'd like to provide both...

IE8 only submits with button, not submit?

So, this is strange, and it was working for me about a month ago, before I made a bunch of code updates. Anyways the issue is the live submit handler wont even run in IE8, however, if i run it on a button click, it works. See below: HTML <label>Add Attachment</label> <form class="file_upload" method="post" enctype="mult...

How to extending Jquery validatation to validate 2 of 3 required phone number?

Hello, I am using jQuery Validation and here is the extension that I am using to validate US phone number. jQuery.validator.addMethod("phoneUS", function(phone_number, element) { phone_number = phone_number.replace(/\s+/g, ""); return this.optional(element) || phone_number.length > 9 && phone_number.match(/...

jQuery animate image zoom flickering

Hi! I'm trying to zoom an image using the jQuery animate function to resize its width and height. But when I change the left position (to center the picture on my "mask"), it's flickering... Someone knows how can I solve this? Or give me a better solution? Thank you all! =] ...

With JS, jQuery, how do I save an AJAX response to a (text) file?

It seems like this question is asked periodically and the common response is "You shouldn't do that with AJAX anyway. Just set the window location to the file." But I'm trying to request a file that doesn't actually exist out on the server anywhere. It's dynamically generated (by a Django view) given the GET/POST context parameters. The...

jQuery: height()/width() and "display:none"

I always thought elements that had "display:none" CSS style returned 0 for height() and width(). But in this example, they don't: http://jsfiddle.net/Gts6A/2/ How come? I've seen 0 come back plenty of times in the past. ...

what's a good form-checking library with conditional validation?

I had been using jsvalidate, but it doesn't fit my requirement of conditional validation for what I want to do; I want to make a couple of fields required only if a select is previously marked as yes. I have been looking into mootools's formcheck, it seems a bit fancier and nicer than jquery's validation plugin, but I don't know if it w...

json response into an array

Hi guys, What's the best way to get a json response into an array that I can use in the below example? This is my function that calls triggers the ajax call: function getMaps(){ mapID = "aus"; mapImg = 'map_australia.jpg'; $.ajax({ type: "GET", url: "getMap.asp", data: "id=" + mapID, content...

jQuery: On focus in textarea, Remove default text + change color , on unfocus - put text back

This is a very common usecase we see on stackoverflow, facebook, etc. You often want to give the user some text to direct him on what to do, but you want the text to disappear the moment he clicks on it. What is the easiest way to do that via JQuery? This seems like a fairly common use case ...

Using <div class="something"> inside a jQuerty replaceWith() function

I am working on a PHP document which has jQuery code in it. I am using a replaceWith() functions to strip outer divs and replace with span. it seems I can only replace it with <span> and not <span class="something"> Why is that? Edit: Here is an example of the code: Thanks Dave, but I actually use the second option in your code above,...

Jquery move table row up or down or move X

I saw the example but no idea how due to fresh to jquery, is that any way to remove "up" key when it reach to the top and remove "down" key when it is the bottom. And also, I need have a input to move my certain row to another row, eg: row 1,2,3 and move row 1 to 3 just input 3 and press submit and it move. Is that any example or tu...

How can I add multi-column sorting to jqgrid?

I can add single column sorting to jqgrid, no problem. How can I add multi-column sorting to jqgrid? That is, sort by column 1, then sort by column 2, the final sort order is: column 2, column 1 ...

Yes/No confirmation message

I'm trying to get an alert message with Yes/No option, where clicking on 'Yes' reloads a another drop-down option, and 'No' would revert back to the previous selection. Here is what I'm trying to say (obviously doesn't work): <select size="1" name="m" id="m"> <option selected value="1">apple</option> <option value="2">ball</op...

JQuery not Working in chrome?

Hi Everyone! I am trying to change the background-image of a div by altering it's CSS via Jquery and I got it to work in FireFox but for some reason its not doing anything in chrome, I tried clearing the cache but still no luck, there's no errors in the console either, Here's my code: $(document).ready(function() { var bg = 1; $(...

How to populate the page via JQuery after I have the json returned

Ok so i have the json object returned back from my script and I have all the data but how do I put it on the page. Here is what i have so far I have a php page which has a loop like this <div class="main-blue"> <div class="blue-items"> <?php foreach ($related as $row_r) { ?> <div class="item-blue"> <div class="image left"> <img src="<...