Skip to content

When a 'root' is specified while instancing a new Resthub.View, the view's el is inserted in the DOM during the instanciation #145

@notslackingatwork

Description

@notslackingatwork

Hi,

The title says it all.
if you instanciate a view extending Resthub.View that has a "root" value defined in it, or if root is specified in the options object, this view's el will be attached to the root element during the instanciation, even if "render" is never called. I don't think this should be the case.

example :
function (Resthub) {
var Popin = Resthub.View.extend({
className: 'test',
});
return Popin;
});

new Popin(); --> $el is attached
new Popin({root:"body"}); --> $el is atttached to the body during this call.

apparently, the el gets attached to the root element in the Resthub method "_insertRoot".
The call stack is as follows :

(backbone.js) View ( http://backbonejs.org/docs/backbone.html#section-120 )
(backbone.js) _ensureElement ( http://backbonejs.org/docs/backbone.html#section-133)
(resthub.js) setElement
(resthub.js) _insertRoot

Maybe this behavior should be moved to the render ?

Thanks,
Léo.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions