On Mon, Nov 5, 2012 at 9:12 PM, ladd.james <
ladd....@gmail.com> wrote:
> I have tried the following and I get:
>
> Uncaught Error: evento.addEventListener: Supported EventTarget interface not
> found.
>
> I'm passing in what I think is a valid rootEl - and - my buildTemplate has
> no
> body. Just like below.
>
> I went down this path because when I'm creating a View I want the 'template'
> inserted
> before the element identified by 'getContainerEl' but I could not achieve
> that.
If a view has child views then the the child views nodes should be
descendents of the view's node. They child view's nodes will not come
after the view's nodes.
> Instead
> opting to manually make the element in a higher template and then 'attach'
> to it in
> a subview.
>
> A working example of attaching a Maria view to existing HTML (ie: no
> template file) would
> be very helpful.
I had a mistake. The view's rootEl property cannot be set until after
the build process happens as the build process will not happen if the
rootEl has already been set. Storing in a rootToBe property works...
<!DOCTYPE html>
<html>
<head>
<title>No Template</title>
</head>
<body>
<div id="wrapper">
<p class="clickable">click me</p>
</div>
<script src="
http://michaux.ca/downloads/maria/rc4/maria.js"
type="text/javascript"></script>
<script type="text/javascript">
var myApp = {};
maria.ElementView.subclass(myApp, 'MyView', {
constructor: function(rootEl) {
maria.ElementView.call(this);
this._rootToBe = rootEl;
},
uiActions: {
'click .clickable': 'onClickClickable'
},
properties: {
buildTemplate: function() {
this._rootEl = this._rootToBe;
}
}
});
maria.Controller.subclass(myApp, 'MyController', {
properties: {
onClickClickable: function() {
alert('was clicked');
}
}
});
maria.addEventListener(window, 'load', function() {
var view = new myApp.MyView(document.getElementById('wrapper'));
view.build();
});
</script>
</body>
</html>
Peter