I'm currently trying to call only fields with certain attributes. Since I'm no jquery expert, I took the "add all" button as a guide and updated it to serve my purpose. So far, I haven't received the results I was expecting.
Down below is the original "add - all" code which adds all "li" from the left side of a table to the right.
this.container.find(".add-all").click(function() {
var options = that.element.find('option').not(":selected");
if (that.availableList.children('li:hidden').length > 1) {
that.availableList.children('li').each(function(i) {
if (jQuery(this).is(":visible")) jQuery(options[i-1]).attr('selected', 'selected');
});
} else {
options.attr('selected', 'selected');
}
that._populateLists(that.element.find('option'));
return false;
});
This is the code that generates the "li".
_getOptionNode: function(option) {
option = jQuery(option);
var node = jQuery('<li class="ui-state-default ui-element " title="'+option.text()+'" data-selected-value="' + option.val() + '" industry = "'+ option.attr("class")+'" ><span class="ui-icon"/>'+option.text()+'<a href="#" class="action"><span class="ui-corner-all ui-icon"/></a></li>').hide();
node.data('optionLink', option);
return node;
I tried updating the "add all" code in order to call only the industry attribute. This is what I tried...
this.container.find(".add-auto").click(function() {
var options = that.element.find('option').not(":selected");
if (that.availableList.children('li:hidden').length > 1) {
that.availableList.children('li').each(function(i) {
if (jQuery(this).is(":visible") && jQuery(this).find("[industry = 'auto']")) jQuery(options[i-1]).attr('selected', 'selected');
});
} else {
that.availableList.children('li').each(function (i) {
if (jQuery(this).find("[industry = 'auto']")) jQuery(options[i-1]).attr('selected','selected');
});
}
that._populateLists(that.element.find('option'));
return false;
});
This is what the inspect in the actual page brings up. Also , for some reason I'm getting an extra apostrophe in the industry = "auto'". Will this affect the end results? If so, how could I fix this?