I have a Component and showing it dynamically when a user clicks on a button.
I toggle a variable to insert the component into the DOM and inserting some new content inside the component.
But when I toggle the variable the component is inserted inside the DOM but my new content is not loaded inside the component.
Template:
<script type="text/x-handlebars" data-template-name="index">
<div {{action showDialogComponent}}>Show Dialog</div>
<div {{action showDialogComponent1}}>Show Dialog1</div>
{{#if showDialog}}
{{temp-dialog}}
{{/if}}
</script>
Components:
<script type="text/x-handlebars" data-template-name="components/temp-dialog">
<div id="dialogdiv"> This is a dilaog div.</div>
</script>
JavaScript:
App.IndexRoute = Ember.Route.extend({
actions:{
showDialogComponent: function(){
this.controller.set('showDialog', true);
$('#dialogdiv').html('New Content Loaded.');
},
showDialogComponent1: function(){
this.controller.set('showDialog', true);
$('#dialogdiv').html('New Content1111 Loaded.');
}
});
App.IndexController = Ember.Controller.extend({
showDialog: false
});
App.TempDialogComponent = Ember.Component.extend({
didInsertElement: function(){
// But need to load different content based on the context.
// $('#dialogdiv').html('New Content Loaded.');
}
});
If the data loaded is unique I can add the data in didInsertElement hook.
How can I add my new content inside my component based on the click action triggered on the Route.
JSBin --> Link
But need to load different content based on the context.
That sounds like a good reason to use a block component. Is that an option for you? – GJK