Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

trying to add delete button

  • Loading branch information...
commit 1f605a552aa45bd277c7534ecb46db537266df83 1 parent 3d3c138
@qoobaa authored
Showing with 13 additions and 7 deletions.
  1. +3 −0  index.html
  2. +10 −7 lib/main.js
View
3  index.html
@@ -16,6 +16,9 @@
{{#collection contentBinding="Ficha.cardsController" tagName="ul"}}
{{content.front}} {{content.back}}
+ {{#view SC.Button target="Ficha.cardsController" action="delete"}}
+ Delete
+ {{/view}}
{{/collection}}
</script>
</body>
View
17 lib/main.js
@@ -12,7 +12,11 @@ Ficha.Card = SC.Object.extend({
});
Ficha.cardsController = SC.ArrayController.create({
- content: []
+ content: [],
+
+ delete: function (a) {
+ console.log(a);
+ }
});
Ficha.cardController = SC.Object.create({
@@ -27,17 +31,16 @@ Ficha.cardController = SC.Object.create({
},
createCard: function () {
- Ficha.cardsController.pushObject(this.get("currentCard"));
- this.newCard();
- },
-
- sideViewInsertNewline: function (event) {
var currentCard = this.get("currentCard");
if (currentCard.get("isValid")) {
- this.createCard();
+ Ficha.cardsController.pushObject(this.get("currentCard"));
+ this.newCard();
}
+ },
+ sideViewInsertNewline: function (event) {
+ this.createCard();
setTimeout(function () {
$(event.target).parents(".sc-view").find("input[type='text'][value='']:first").focus();
}, 0);
Please sign in to comment.
Something went wrong with that request. Please try again.