AmpersandJS / ampersand-input-view

A view module for intelligently rendering and validating input. Works well with ampersand-form-view.
MIT License
17 stars 19 forks source link

`template` option is being ignored #4

Closed kahlil closed 10 years ago

kahlil commented 10 years ago

In the ampersand example app I tried to pass this template:

<div class="pure-control-group">
  <div role="message-container">
    <p role="message-text"></p>
  </div>
  <label for="name" role="label"></label>
  <input id="name" type="text">
</div>

without any effect.

kamilogorek commented 10 years ago

Did you pass template on an instance initialization

var view = new InputView({
    template: '...'
});

or extanded a new custom view?

var CustomInputView = InputView.extend({
    template: '...'
});
var view = new CustomInputView();
kahlil commented 10 years ago

on an instance initialization

kamilogorek commented 10 years ago

Then it won't work. Internal attributes like template are only mixed once base constructor is extended. You've to create custom view for that.

kamilogorek commented 10 years ago

Attributes that can be passed along on initialization are only model, collection and elhttps://github.com/AmpersandJS/ampersand-view/blob/76cb498b2969511ba4aaa5620edd32f63f4652d2/ampersand-view.js#L78

kahlil commented 10 years ago

OK got it, thanks.