Skip to content

Commit

Permalink
ability to customize the way list label gets extracted from the option
Browse files Browse the repository at this point in the history
  • Loading branch information
vicb committed Jul 7, 2010
1 parent 2b120a2 commit 39887ad
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
6 changes: 6 additions & 0 deletions README.md
Expand Up @@ -69,6 +69,11 @@ based on asmSelect - Alternate Select Multiple by Ryan Cramer
* Keeps original select multiple visible so that you can monitor live changes made to it when debugging.
* Default: false

* extractLabel:

* A function to compute the list element name from the option object
* Default: extract the option html

### Text Labels ###

* title
Expand Down Expand Up @@ -141,6 +146,7 @@ github latest:
* support for optgroup
* ability to set the default select title via the configuration
* make the original label point to the new select
* ability to customize the way list label gets extracted from the option

2010-07-02:

Expand Down
4 changes: 3 additions & 1 deletion examples/index.html
Expand Up @@ -100,7 +100,8 @@
listClass: 'bsmList-custom', // Class for the list ($ol)
listItemClass: 'bsmListItem-custom', // Class for the <li> list items
listItemLabelClass: 'bsmListItemLabel-custom', // Class for the label text that appears in list items
removeClass: 'bsmListItemRemove-custom' // Class given to the "remove" link
removeClass: 'bsmListItemRemove-custom', // Class given to the "remove" link
extractLabel: function($o) {return ">>" + $o.html();}
});

});
Expand Down Expand Up @@ -207,6 +208,7 @@ <h3>Execizing the features added over asmSelect</h3>
<li>Custom effects</li>
<li>Option groups</li>
<li>Setting the title in the configuration</li>
<li>Customize the way list element labels get extracted</li>
</ul>

<form action="./example_results.php" method="post">
Expand Down
4 changes: 3 additions & 1 deletion jquery.bsmselect.js
Expand Up @@ -14,6 +14,7 @@
* - support for optgroup
* - ability to set the default select title via the configuration
* - make the original label point to the new select
* - ability to customize the way list label gets extracted from the option
* v1.0 - 2010-07-02:
* - initial release
*
Expand Down Expand Up @@ -224,7 +225,7 @@

var $itemLabel = $("<span>", {
"class": conf.listItemLabelClass,
html: $O.html()
html: conf.extractLabel($O, conf)
});

var $item = $("<li>", {
Expand Down Expand Up @@ -357,6 +358,7 @@
removeLabel: 'remove', // Text used in the "remove" link
highlightAddedLabel: 'Added: ', // Text that precedes highlight of added item
highlightRemovedLabel: 'Removed: ', // Text that precedes highlight of removed item
extractLabel: function($option) { return $option.html(); },

containerClass: 'bsmContainer', // Class for container that wraps this widget
selectClass: 'bsmSelect', // Class for the newly created <select>
Expand Down

0 comments on commit 39887ad

Please sign in to comment.