Ember.js + Handlebars user assistant

I am trying to implement a simple conditional statement in Handlebars that changes based on an attribute in my controller.

I managed to find:

Handlebars.registerHelper("businessVerificationState", function(state, block) {
  var value = Ember.getPath(this, "state");
  if (value == state) {
    return block(this);
  }
});

App.businessController.business refers to the model object that I created, and "state" is an attribute. Below is the template.

<script type="text/x-handlebars">
  {{#with App.businessController.business}}
    {{#exampleState "test1"}}
      <p>Test 1</p>
    {{/exampleState}}

    {{#exampleState "test2"}}
      <p>Test 2</p>
    {{/exampleState}}
 </script>

All this swells. Except when my model attributes change. From the console in webkit .. if I type ..

business.set ("state", "test2"); for example, nothing changes.

If I use other standard steering descriptors, such as IF or UNLESS, the content change is based on updating the model attributes.

Obviously, I am doing something incredibly wrong and would appreciate any help.

+5
1

- , , , , . isVisible, , .

:

<script type="text/x-handlebars">
  {{#view Ember.View currentStateBinding="App.businessController.business.state"}}
    {{#view App.StateView stateName="test1"}}
      <p>Test 1</p>
    {{/view}}

    {{#view App.StateView stateName="test2"}}
      <p>Test 2</p>
    {{/view}}
  {{/view}}
</script>

JS:

var App = Ember.Application.create();

App.businessController = Ember.Object.create({
    business: Ember.Object.create({
        state: 'test1'
    })
});

App.StateView = Ember.View.extend({
    isVisible: function() {
        return this.get('stateName') === this.getPath('parentView.currentState');
    }.property('parentView.currentState')
});

jsFiddle: http://jsfiddle.net/ebryn/QAxPU/

+5

All Articles