We use prototype.js for javascript but we are now implementing the Kendo UI DatePicker and I am confused on how to approach an issue. Given the following:
function MyClass()
{
this.Name = $('inputName');
this.LastName $('inputLastName');
this.GridViewInputs;
}
MyClass.prototype.init = function()
{
//some event observe methods here
}
MyClass.protype.setUpDatePickers = function()
{
//grab all input values from a gridview and attach a date picker to each
this.GridViewInputs = $$('.Dates');
//HERE IS MY PROBLEM, I AM NOT SURE HOW TO CALL THE FUNCTION BELOW FROM HERE
//AND PASSING IT EACH INPUT
}
$j(document).ready(function() {
// create DatePicker from input HTML element
$(myInput passed here).kendoDatePicker();
});
The problem i have is that I cant really use this.GridViewInputs inside the $j function because it would say its not recognized, I believe because it's outside the object.
Why don't you call the setUpDatePickers
method inside the document ready function?
2 ways to call it - either after you have created an instance of MyClass
var t = new MyClass();
t.setupDatePickers();
or directly from the prototype
MyClass.protype.setUpDatePickers()
If you call it directly from the prototype you do not have this
available - so it might not be the best way
Also inside of MyClass.protype.setUpDatePickers
to put the date pickers on the inputs you'll need to do one of the following - I'm not exactly sure if the first one will work as I haven't used kendo before - but the 2nd one will work.
$$('.Dates').invoke('kendoDatePicker');
//
//OR
//
$$('.Dates').each(function(input){
input.kendoDatePicker();
});