Skip to content

Instantly share code, notes, and snippets.

@devdays
Last active August 29, 2015 14:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save devdays/ec007933ce7ceabe7910 to your computer and use it in GitHub Desktop.
Save devdays/ec007933ce7ceabe7910 to your computer and use it in GitHub Desktop.
Client code for displaying widget
$("#cheeses").filterable({
className: "cheese",
create: function() { $("#register").addClass("ui-widget-header cheese").show(); },
filtered: function(e, ui) {
var t = 0;
ui.visible.each(function() { t = t + parseFloat($(this).data("price")); });
console.log( t );
total.text(t.toFixed(2));
},
setOption: function(e, ui) {
ui.option == "className" && $("#register").toggleClass([ui.original, ui.current].join(" "));
},
hover: function(e, ui) {
if (e.originalEvent.type == "mouseenter") {
price.text(" - " + ui.hovered.data("price") + " per lb").appendTo(ui.hovered);
} else {
price.detach();
}
}
});
setTimeout(function() { cheeses.filterable("option", "className", "cheesePlease"); },3000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment