Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Update js/jquery.multi-select.js #41

Closed
wants to merge 1 commit into from

2 participants

@vedmaka
  • bug binding click on selectableLi -> selectedLi
  • add fix to escaping quotes, breaking everything
@vedmaka vedmaka Update js/jquery.multi-select.js
- bug binding click on selectableLi -> selectedLi
- add fix to escaping quotes, breaking everything
00a0e11
@lou lou closed this pull request from a commit
@lou fixes #41: escape special chars 82e89a6
@lou lou closed this in 82e89a6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Nov 1, 2012
  1. @vedmaka

    Update js/jquery.multi-select.js

    vedmaka authored
    - bug binding click on selectableLi -> selectedLi
    - add fix to escaping quotes, breaking everything
This page is out of date. Refresh to see the latest.
Showing with 14 additions and 4 deletions.
  1. +14 −4 js/jquery.multi-select.js
View
18 js/jquery.multi-select.js
@@ -49,8 +49,13 @@
optgroupLabel+'</li></ul></li>'));
optgroupCpt++;
} else {
+
+ $(this).val($(this).val().split('"').join('&quot;'));
+ $(this).val($(this).val().split("'").join('&#39;'));
+ $(this).val($(this).val().replace(/"/gi,'&quot;'));
+
var klass = $(this).attr('class') ? ' '+$(this).attr('class') : '';
- var selectableLi = $('<li class="ms-elem-selectable'+klass+'" ms-value="'+$(this).val()+'">'+$(this).text()+'</li>');
+ var selectableLi = $('<li class="ms-elem-selectable'+klass+'" ms-value="'+escapeQuotes($(this).val())+'">'+$(this).text()+'</li>');
if ($(this).attr('title'))
selectableLi.attr('title', $(this).attr('title'));
@@ -178,13 +183,18 @@
$(this).multiSelect("init", $(this).data("settings"));
},
'select' : function(value, method){
+
+ value = value.split('"').join('&quot;');
+ value = value.split("'").join('&#39;');
+ value = value.replace(/"/gi,'&quot;');
+
var ms = this,
selectedOption = ms.find('option[value="'+value +'"]'),
text = selectedOption.text(),
klass = selectedOption.attr('class'),
titleAttr = selectedOption.attr('title');
- var selectedLi = $('<li class="ms-elem-selected'+(klass ? ' '+klass : '')+'" ms-value="'+value+'">'+text+'</li>'),
+ var selectedLi = $('<li class="ms-elem-selected'+(klass ? ' '+klass : '')+'" ms-value="'+escapeQuotes(value)+'">'+text+'</li>'),
selectableUl = $('#ms-'+ms.attr('id')+' .ms-selectable ul'),
selectedUl = $('#ms-'+ms.attr('id')+' .ms-selection ul'),
selectableLi = selectableUl.children('li[ms-value="'+value+'"]'),
@@ -211,11 +221,11 @@
selectedLi.addClass(ms.data('settings').disabledClass);
} else {
if(ms.data('settings').dblClick) {
- selectableLi.dblclick(function(){
+ selectedLi.dblclick(function(){
ms.multiSelect('deselect', $(this).attr('ms-value'));
});
} else {
- selectableLi.click(function(){
+ selectedLi.click(function(){
ms.multiSelect('deselect', $(this).attr('ms-value'));
});
}
Something went wrong with that request. Please try again.