Few notes:
Wait for “shown.bs.modal”
I don’t use Bootstrap, but in their documentation about the modal component, the first block of example code is this:
$('#myModal').on('shown.bs.modal', function () {
$('#myInput').trigger('focus')
})
It’s probably a good idea to interact with the modal only once it’s been shown, something like this:
'click #laucnhdateRangeModal'(e,t) {
$('#dateRangeModal').on('shown.bs.modal', function () {
$('input[name="birthday"]').daterangepicker({ parentEl: $('#dateRangeModal'), showDropdowns: true});
});
$('#dateRangeModal').modal('show');
},
Follow the daterangepicker API
In the DateRangePicker documentation the parentEl
prop is defined as a string, a selector. You are passing down a jQuery object.
-
parentEl
: (string) jQuery selector of the parent element that the date range picker will be added to, if not provided this will be ‘body’
So change that to:
$('input[name="birthday"]').daterangepicker({ parentEl: '#dateRangeModal', showDropdowns: true});
Beware of “if” clauses in templates and template inclusions when your third party code is operating “across template borders”
Your scheduleEventFormPartial
is trying to trigger the modal using a DOM element that’s defined in it’s child template, dateRangeModal
.
Also the input
element you are trying to use as the base for DateRangePicker is behind an if
-clause:
{{#if equals currentDateRangeType "DateRange"}}
show calendar
<input type="text" name="birthday" value="" />
</p>
{{/if}}
Are you sure those elements exist in DOM when you are trying to manipulate them from the parent element?
(…and there is also some dangling </p>
closing tag in there…? I don’t think this should even compile.)
Regarding the console.logs
You include the dateRangeModal
-component directly in the parent template, so it should be created and rendered immediately. Clicking the #launchdateRangeModal
link only triggers the jQuery-Bootstrap-sorcery on the specified DOM elements.
I recommend you refactor your code so that any Bootstrap-initializations happen inside the same template/component’s onRendered
function where the target element(s) reside(s).
Hope these help!