1

Adding stub for deleting categories

This commit is contained in:
Alex Yatskov 2015-03-11 22:43:31 +09:00
parent 3dd296def2
commit 7bdf03f159
2 changed files with 18 additions and 7 deletions

View File

@ -22,14 +22,15 @@
<td class="text-left">{{description}}</td> <td class="text-left">{{description}}</td>
<td class="text-right"> <td class="text-right">
<label class="radio-inline"> <label class="radio-inline">
<input type="radio" name="category_{{id}}" categoryId="{{id}}" value="1" {{checkMatch 1}}> Agree <input type="radio" name="category_{{id}}" data-categoryId="{{id}}" value="1" {{checkMatch 1}}> Agree
</label> </label>&nbsp;
<label class="radio-inline"> <label class="radio-inline">
<input type="radio" name="category_{{id}}" categoryId="{{id}}" value="-1" {{checkMatch -1}}> Disagree <input type="radio" name="category_{{id}}" data-categoryId="{{id}}" value="-1" {{checkMatch -1}}> Disagree
</label> </label>&nbsp;
<label class="radio-inline"> <label class="radio-inline">
<input type="radio" name="category_{{id}}" categoryId="{{id}}" value="0" {{checkMatch 0}}> Neither <input type="radio" name="category_{{id}}" data-categoryId="{{id}}" value="0" {{checkMatch 0}}> Neither
</label> </label>&nbsp;
<button type="button" data-categoryId="{{id}}" class="btn btn-xs btn-danger">&times;</button>
</td> </td>
</tr> </tr>
{{/each}} {{/each}}

View File

@ -50,12 +50,22 @@
}); });
} }
function removeCategory(id) {
alert('Delete stub');
}
function displayCategories(categories) { function displayCategories(categories) {
var template = Handlebars.compile($('#template').html()); var template = Handlebars.compile($('#template').html());
$('#categories').append(template({categories: categories})); $('#categories').append(template({categories: categories}));
$('#categories input:radio').change(function() { $('#categories input:radio').change(function() {
setProfileValue($(this).attr('categoryId'), this.value); setProfileValue($(this).attr('data-categoryId'), this.value);
});
$('#categories button').click(function() {
if (confirm('Are you sure you want to delete this category?')) {
removeCategory($(this).attr('data-categoryId'));
}
}); });
} }