Skip to content

Commit

Permalink
Edit book form - Handlebars if_eq helper replaced by if helper (separ…
Browse files Browse the repository at this point in the history
…ating viev layer from controller)
  • Loading branch information
beatrycze committed Apr 18, 2017
1 parent b780acb commit ae8baa1
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 11 deletions.
8 changes: 1 addition & 7 deletions app.js
Expand Up @@ -61,6 +61,7 @@ var app = {
removeSpinner();
$('#container').html(app.templates.editBookFormTemplate({
title: 'Something changed? Update it!',
displayBorrowedCheckbox: responses[0].bookTypeId === 1,
book: responses[0],
bookTypes: responses[1],
bookForms: responses[2],
Expand Down Expand Up @@ -260,10 +261,3 @@ Handlebars.registerHelper('selected', function(option, value){
return ''
}
});

// https://code-maven.com/handlebars-conditionals
Handlebars.registerHelper('if_eq', function(a, b, opts) {
if (a == b) {
return opts.fn(this);
}
});
6 changes: 2 additions & 4 deletions index.html
Expand Up @@ -188,9 +188,7 @@ <h2>{{title}}</h2>
</select>
</div>
</div>
{{#if_eq book.bookTypeId 1}}
<!--Handlebars if_eq helper:
https://code-maven.com/handlebars-conditionals-->
{{#if displayBorrowedCheckbox}}
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<div class="checkbox">
Expand All @@ -203,7 +201,7 @@ <h2>{{title}}</h2>
</div>
</div>
</div>
{{/if_eq}}
{{/if}}
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<button type="submit" id="save-changes-btn" class="btn btn-success">Save</button>
Expand Down

0 comments on commit ae8baa1

Please sign in to comment.