Note that there are some explanatory texts on larger screens.

plurals
  1. POPass values from MVC controller to javascript code
    primarykey
    data
    text
    <p>I need to pass list/json/array of dates information to a Jquery UI Datepicker dynamically through a jsonresult in a MVC controller. </p> <p>Following the link below, I am able to highlight selected dates in the datepicker control. <a href="http://jquerybyexample.blogspot.com/2012/05/highlight-specific-dates-in-jquery-ui.html" rel="nofollow">http://jquerybyexample.blogspot.com/2012/05/highlight-specific-dates-in-jquery-ui.html</a></p> <pre><code> &lt; script type ="text/javascript"&gt; $(document).ready( function () { var SelectedDates = {}; SelectedDates[ new Date('05/28/2012' )] = new Date( '05/28/2012' ); SelectedDates[ new Date('05/29/2012' )] = new Date( '05/29/2012' ); SelectedDates[ new Date('05/30/2012' )] = new Date( '05/30/2012' ); //want to replace the above three lines with code to get dates dynamically //from controller $( '#releasedate' ).datepicker({ dateFormat: "mm/dd/yy" , numberOfMonths: 3, duration: "fast" , minDate: new Date(), maxDate: "+90" , beforeShowDay: function (date) { var Highlight = SelectedDates[date]; if (Highlight) { return [true , "Highlighted", Highlight]; } else { return [true , '', '' ]; } } }); </code></pre> <p>The above code will highlight those specific three dates on the calendar control(UIDatepicker).Instead of hard coding dates like above... My challenge is to get these dates dynamically from a controller and pass it on to the var SelectedDates in javascript above.</p> <p>Controller jsonresult code:</p> <pre><code> public JsonResult GetReleasedDates(string Genre) { var relDates = service.GetDates(Genre)//code to get the dates here return Json(relDates, JsonRequestBehavior .AllowGet); //relDates will have the dates needed to pass to the datepicker control. } </code></pre> <p>Thanks for the help.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload