1

I have the following model which is wrapped in my view model i want to pass MaximumDaysAheadBookable property to datepicker function

public class SessionObject
{    
    public int MaximumNumberOfRooms { get; set; }
    public int MaximumNumberOfAdultsPerRoom { get; set; }
    public int MaximumNumberOfChildrenPerRoom { get; set; }
    public int MaximumDaysAheadBookable { get; set; }
    public int MaximumDaysBetweenCheckinCheckout { get; set; }
}

How do I access one of the above properties from Javascript.js file ? then pass it to datepicker function :

$('document').ready(function () {
   $("#Arrival").datepicker({
        minDate: 0,
        maxDate:MaximumDaysAheadBookable , ////here i want to pass model value 
        dateFormat: 'dd/mm/yy',
        showOn: "button",
        buttonImage: "img/ui_cal_icon.gif",
        buttonImageOnly: true,
        buttonText: "Select date",

    });
 });
ahosam
  • 97
  • 5
  • 18
  • 1
    Server side (razor) code is not parsed in external files. You need to declare it in the main view (e.g. `var maxDate = @Model.MaximumDaysAheadBookable;` and then in the external file - `maxDate: maxDate,` –  May 10 '17 at 09:16
  • There has to be a duplicate – Satpal May 10 '17 at 09:17
  • @StephenMuecke this is what i want correctly , thanks – ahosam May 10 '17 at 11:12

1 Answers1

0

In a external js file you will need to pass the data as a parameter.

Joel Pinto Ribeiro
  • 603
  • 1
  • 6
  • 11