0

I am trying to render javascript in all views .this java file is for datetimepicker that i use in my views :

    <script>
               Calendar.setup({
                   inputField: 'date_input',
                   button: 'date_btn',
                   ifFormat: '%Y/%m/%d',
                   dateType: 'jalali'
               });
</script>  

I have to put in every views this script ,but it's not a good idea!!!so i put this script in header of layout page ,but i got this error when my pages is refreshed :

enter image description here

So where should i put this script to avoid this error ????

best regards .

any ideas will be appreciated .

Ehsan Akbar
  • 5,728
  • 15
  • 72
  • 137
  • 2
    Learn about [sections](http://stackoverflow.com/questions/13089489/asp-net-mvc-explanation-of-section) in MVC views. If its in the `header` but not wrapped in `document.Ready` then it runs before the html elements are created –  Oct 18 '14 at 09:40
  • @StephenMuecke where should i put this code to render after html ? – Ehsan Akbar Oct 18 '14 at 09:45
  • Scripts should ideally be immediately before the closing `

    ` tag

    –  Oct 18 '14 at 09:47
  • i put after

    but again same error

    – Ehsan Akbar Oct 18 '14 at 10:21
  • 1
    _after_ is not the same as _immediately before_! What is `Calendar.setup`? –  Oct 18 '14 at 10:25
  • No matter where you place it, the code will execute immediately as there is no $(document).ready(). It will be nice if you include a sample page as well with a bit more code – Chris Oct 20 '14 at 11:32

0 Answers0