Skip to content

Commit

Permalink
Fix bugs with select lists
Browse files Browse the repository at this point in the history
  • Loading branch information
saxap committed Dec 22, 2013
1 parent 688528f commit 29e2293
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
2 changes: 1 addition & 1 deletion grab-gets.jquery.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"checkbox",
"radio"
],
"version": "1.0.3",
"version": "1.0.4",
"author": {
"name": "Sergey Astafev (saxa:p)",
"url": "http://dontforget.pro",
Expand Down
16 changes: 9 additions & 7 deletions jquery.grab-gets.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
/*!
* jQuery grabget plugin
* Description: Grab GET parameters from url and put, select and check elements of selected form
* version: 1.0.1-2013.11.10
* version: 1.0.4-2013.22.12
* Requires jQuery v1.2 or later
* Autor: saxa:p (http://dontforget.pro)
* Email: [email protected]
* Examples and documentation at: http://malsup.com/jquery/form/
* Project repository: https://github.com/malsup/form
* Dual licensed under the MIT and GPL licenses.
Expand All @@ -18,16 +17,17 @@
$.extend({
getUrlVars: function(re){
var vars = [], hash;
var h0 = '';
var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
for(var i = 0; i < hashes.length; i++)
{
hash = hashes[i].split('=');
h0 = hash[0];
if (!re) {
vars.push(hash[0]);
vars[hash[0]] = hash[1];
} else {
vars.push(hash[1]);
vars[hash[1]] = hash[0];
} else {
vars[decodeURIComponent(hash[1])] = decodeURIComponent(h0);
}
}
return vars;
Expand Down Expand Up @@ -70,14 +70,16 @@
form.find('select').each( function() {
var iname = $(this).attr('name');
$(this).find('option').each( function() {
if ( $.inArray($(this).val(), arr) !== -1 ) {
var ival = $(this).val();
if ( arr[ival] == iname ) {
$(this).attr('selected', 'selected');
}
});
});
form.find('input[type="checkbox"], input[type="radio"]').each( function() {
var iname = $(this).attr('name');
if ( $.inArray($(this).val(), arr) !== -1 ) {
var ival = $(this).val();
if ( arr[ival] == iname ) {
$(this).attr('checked', 'checked');
}
});
Expand Down
4 changes: 2 additions & 2 deletions jquery.grab-gets.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 29e2293

Please sign in to comment.