I created editor and display templates for my entire object downline.
Now one of the inner objects' text boxes should be a date-picker.
The thing is it's loaded after the initial loading using Ajax
, and the included scripts don't work.
I tried to include the following script on the bottom of the template, the script renders but does nothing:
@Styles.Render("~/Content/themes/base/css")
@Scripts.Render("~/bundles/jquerytimepicker")
<script type="text/javascript">
alert('dddddddddddddddddddddddddd');
$('.time-picker').timepicker();
</script>
In the code abve I also added a dummy alert just to prove that the script isn't running, which makes the question much simpler: "How to run scripts from templates and partial views?".
I tried to include the scripts in a section define in the outer page, but that doesn't work, as templates and partial view cannot include sections by design (Read this).