最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Meteor with blaze UI.Insert to specific div - Stack Overflow

programmeradmin1浏览0评论

i wanna to ask how to render and insert template to specific div. As we know from meteor wiki, this how to do that :

UI.insert(UI.render(Template.something), document.body);

and i place that to rendered or onAfterAction on IronRouter map, and it works. I have a div with id = "content", i wanna place the Template.something to that div, so i try with ordinary query code-like :

UI.insert(UI.render(Template.something), $('#content'));

and i place that to rendered or onAfterAction on IronRouter map, but it doesn't works. please help me how to render and insert to specific div? thanks

i wanna to ask how to render and insert template to specific div. As we know from meteor wiki, this how to do that :

UI.insert(UI.render(Template.something), document.body);

and i place that to rendered or onAfterAction on IronRouter map, and it works. I have a div with id = "content", i wanna place the Template.something to that div, so i try with ordinary query code-like :

UI.insert(UI.render(Template.something), $('#content'));

and i place that to rendered or onAfterAction on IronRouter map, but it doesn't works. please help me how to render and insert to specific div? thanks

Share Improve this question asked Apr 1, 2014 at 6:14 yozawiratamayozawiratama 4,32812 gold badges65 silver badges108 bronze badges 3
  • 1 How to get DOM node from a jQuery selector – user728291 Commented Apr 1, 2014 at 6:35
  • Sorry, i had tried it before, but it didn't work – yozawiratama Commented Apr 1, 2014 at 6:40
  • Have you tried using yield? It seems it is designed for what you're trying to do. – Tomasz Lenarcik Commented Apr 1, 2014 at 8:17
Add a ment  | 

1 Answer 1

Reset to default 8

As the documentation says, UI.insert() expects a DOM node as its second argument.

UI.insert( UI.render( Template.something ), $( '#content' ).get(0) ));

If that is not working then try both Template.something and $( '#content' ).get(0) in then dev console to see what values they have.

发布评论

评论列表(0)

  1. 暂无评论