Reputation: 428
I have a form template/component that only shows an input field after a few options are selected, like the type of filter, and in the case of a date I would like to show a data picker on the input field, however I can't seem to be able to get a callback for just the input field without creating another view just for the input field, the template it's a simple if like this
{{#if showTextBox}}
{{input type="text" value=search_term classNames="addFilterInput"}}
{{/if}}
is there anyway to get a callback when the input shows up?
Upvotes: 0
Views: 48
Reputation: 1438
You can extend ember built-in TextField view or you can reopen it. It is up to you but my suggestion is extend TextField.
//views/customInput.js
import Em from 'ember';
export default TextField.extend({
onDidInsertElement: function() {
console.log('here we go');
}.on('didInsertElement')
});
{{#if showTextBox}}
{{view "customInput" type="text" value=search_term classNames="addFilterInput"}}
{{/if}}
Upvotes: 2