Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Making it so the data attributes of the original option elements get …

…sent to the registered callback function.
  • Loading branch information...
commit 10ea9038b3be9c353f67451120ec98fc9a910b53 1 parent 12e4d51
@weotch authored
Showing with 11 additions and 10 deletions.
  1. +11 −10 droplet/jquery.droplet.js
View
21 droplet/jquery.droplet.js
@@ -157,12 +157,14 @@
selected.parents('form:eq(0)').trigger('change');
$(document).unbind('keyup');
+ //create arguments to pass, starting with the data as base
+ var args = selected.data();
+ args.name = selected.text()
+ args.value = selected.attr('href');
+
// Trigger the callback if one is given
if($.isFunction(opts.change)) {
- opts.change.call(dropletPlaceholder, {
- name: selected.text(),
- value: selected.attr('href')
- }, index);
+ opts.change.call(dropletPlaceholder, args, index);
}
}
@@ -208,18 +210,17 @@
dropletFocusElement.css('width', '0px');
}
- // Generate all anchors inside of the <ul>
+ // Generate all anchors inside of the <ul>
$('option', this).each(function (i) {
- dropletList.append($('<li></li>', {
- 'class': $(this).val().replace(/\s+/g,'_').replace(/[^a-zA-Z0-9_\-]/g,'').toLowerCase()
+ dropletList.append($('<li></li>', {
+ 'class': $(this).val().replace(/\s+/g,'_').replace(/[^a-zA-Z0-9_\-]/g,'').toLowerCase(),
}).html($('<a></a>', {
'class': ($this.val() === $(this).val()) ? 'selected' : '',
href: $(this).val(),
text: $(this).text(),
- click: updateHiddenValue
+ click: updateHiddenValue,
+ data: $(this).data()
})));
-
- });
// Write all the new HTML replacing the given <select>
$(this).before(dropletContainer.append(dropletList)
Please sign in to comment.
Something went wrong with that request. Please try again.