Skip to content

Instantly share code, notes, and snippets.

@ova2
Created May 28, 2012 21:09
Show Gist options
  • Save ova2/2821226 to your computer and use it in GitHub Desktop.
Save ova2/2821226 to your computer and use it in GitHub Desktop.
PickList with Filter (JavaScript)
PrimeFaces.widget.PickList.prototype.filter = function(input, source) {
var $pkitems = source ? this.sourceList : this.targetList;
var escapedInput = input.value.replace(/([()[{*+.$^\\|?])/g, '\\$1');
var re = new RegExp(escapedInput, "i");
$pkitems.find(".ui-picklist-item").show().filter(
function() {
return !re.test(jQuery(this).text());
}).hide();
}
PrimeFaces.widget.PickList.prototype.addAll = function() {
var _self = this;
this.sourceList.children('li:visible.ui-picklist-item').removeClass('ui-state-highlight').hide(_self.cfg.effect, {}, _self.cfg.effectSpeed, function() {
_self.fireOnTransferEvent(this, _self.sourceList, _self.targetList);
_self.transfer(this, _self.targetList);
});
}
PrimeFaces.widget.PickList.prototype.removeAll = function() {
var _self = this;
this.targetList.children('li:visible.ui-picklist-item').removeClass('ui-state-highlight').hide(_self.cfg.effect, {}, _self.cfg.effectSpeed, function() {
_self.fireOnTransferEvent(this, _self.targetList, _self.sourceList);
_self.transfer(this, _self.sourceList);
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment