behaviours.js 599 B

123456789101112131415161718
  1. /**
  2. * State has already changed when this handler is called.
  3. *
  4. * @param event
  5. */
  6. function handleCheckboxClick(event) {
  7. var $target = $(event.target);
  8. var currentState = $target.prop("checked");
  9. var $item = $($target.parentsUntil("ul")[2]);
  10. var newClass = currentState ? "list-group-item-success" : "list-group-item-warning";
  11. var oldClass = currentState ? "list-group-item-warning" : "list-group-item-success";
  12. console.log($item.constructor.prototype);
  13. $item.addClass(newClass).removeClass(oldClass);
  14. }
  15. $(function () {
  16. $("input[type='checkbox']").click(handleCheckboxClick);
  17. });