ASP.NET MVC (razor) using Model in jQuery -


I would like to use a jQuery function based on the property of the model (using ASP.NET MVC3 with razor) :

  jQuery.datepicker.setDefaults (jQuery.datepicker.regional ['xx']);   

or

  jQuery.datepicker.setDefaults (jQuery.datepicker.regional ['yy']);   

Any ideas?

Thanks,

then you can either enter a global variable In your opinion, write something like this:

  & lt; Script language = "javascript" type = "text / javascript" & gt; Var user recieency = 'model' User regigen '; & Lt; / Script & gt;   

Then you can use only the userRegion global variable in your external script.

Another method may be to use jQuery.data () method.

So in your opinion, attach the value of the user to any html element - the body is a good one and then you can get it into your external javascript files.

e.g. Your view ... Maybe layout page (in which case you should put it in the viewback)

    

Then you can like it:

  var userRegion = jQuery.data (document.body, 'user-region'); JQuery.datepicker.setDefaults (jQuery.datepicker.regional [userRegion]);    

Comments