Attach events to button toolbar

Since this is closer to the elements, we can be more sure that we won't have events fire when we don't want them to. For example, if we're viewing the page in a modal, we don't want the event handler living longer than the content itself.
This commit is contained in:
Jonathan Rehm 2017-07-22 11:24:47 -07:00
parent e1a88aa0ab
commit 693c26c2b3
2 changed files with 2 additions and 2 deletions

View File

@ -6,7 +6,7 @@ $("#have_read_cb").on("change", function() {
$(this).closest("form").submit();
});
$(document).on("click", "[data-shelf-action]", function (e) {
$("#shelf-actions").on("click", "[data-shelf-action]", function (e) {
e.preventDefault();
$.get(this.href)

View File

@ -183,7 +183,7 @@
{% if g.user.is_authenticated %}
{% if g.user.shelf.all() or g.public_shelfes %}
<div class="btn-toolbar" role="toolbar">
<div id="shelf-actions" class="btn-toolbar" role="toolbar">
<div class="btn-group" role="group" aria-label="Add to shelves">
<button id="btnGroupDrop2" type="button" class="btn btn-primary btn-sm dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<span class="glyphicon glyphicon-list"></span> {{_('Add to shelf')}}