ciscoheat / mithril-hx

Haxe externs for Mithril (JS MVC framework)
181 stars 12 forks source link

Changing/adding elements to HEAD #17

Closed RudolfVonKrugstein closed 9 years ago

RudolfVonKrugstein commented 9 years ago

I am trying to add elements to the HEAD of the html page. Can this be done from the code? If I do this:

HTML([
    HEAD(...),
    BODY(...),
]);

My final structure in the browser has 2 html/head and body tags (nested into each other). How is this done correctly?

ciscoheat commented 9 years ago

Hello! Interesting issue, I haven't tried to render head before. Fortunately everything worked fine. You define your view like this:

public function view() [
    HEAD(...),
    BODY(...)
];

And mount the class in Browser.document, which is the html element:

static function main() {
    M.mount(cast js.Browser.document, new YourClass());
}

As you see you need to cast Browser.document since this is an unusual case, but it works fine.