My goal is to have a Facebook button that can conditionally display in Ember mode. My template:
{{#if condition}} Click Like: <div class="fb-like fb_edge_widget_with_comment fb_iframe_widget" data-href="http://www.facebook.com/obnob" data-send="false" data-layout="button_count" data-width="100" data-show-faces="false"></div> {{else}} Nothing to like here! {{/if}}
If the condition changes over the life of the page, the HTML code for the button will be inserted and removed accordingly. The problem is that if after the page loads, a div button of a similar button is inserted, the Facebook JavaScript library will not parse it and turn it into a similar button. To do this, you must call FB.XFBML.parse() .
I tried using didInsertElement() hook Ember.View , but this only Ember.View when the view is first inserted into the DOM, and not after it already exists.
I tried to fix this by adding a script tag to the template:
<script>FB.XFBML.parse();</script>
This failed because the script tag interferes with the Metamorph script tags.
Questions
- Does Ember have a hook to run code anytime Metamorph changes the Ember view that has already been shown?
- How do you write script tags in an Ember template without merging Metamorph tags?
source share