Created
September 30, 2019 16:00
-
-
Save harryadel/4a406afc52b873cd60ea3b0feecd05d0 to your computer and use it in GitHub Desktop.
Revisions
-
harryadel created this gist
Sep 30, 2019 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,36 @@ // Rendered DOM // example.html <div class="product"> <img src="{{productImageSource}}" /> <h4>Title</h4> <p>Price {{productPrice}}</p> <button class="add">+</button> <input type="number" id="quantity" /> <button class="subtract">-</button> <span class="subtotal">Subtotal</span> <div class="actionButtons"> <button>Update</button> <button>Delete</button> </div> </div> // example.js Template.example.events({ 'click .add'(event, templateInstance) { let currentValue = $(event.currentTarget) .parent() .siblings(".subtotal") .val() // not sure val() or text() $(event.currentTarget) .parent() .siblings(".subtotal") .val(currentValue + 1); }, 'click .subtract'(event, templateInstance) { // same as above except we subtract ofc } })