I am using the jquery ui date range picker for rails 3.1. I have managed to get this to work but when I try to use any jquery inside any of the view files, I get this error(see it from console) that says “daterangepicker.jQuery.js:62 Uncaught TypeError: Cannot read property ‘left’ of null”.
var rangeInput = jQuery(this);
var options = jQuery.extend({
...
posX: rangeInput.offset().left,
...
})
The line which is in question is:
posX: rangeInput.offset().left, // x position
However, my theory is that the source of the problem stems from the beginning, where rangeInput is defined in this line:
var rangeInput = jQuery(this);
Maybe this is being called before I actually pick dates which is why the error is coming and why it seems to stop my jquery from running? Thanks for any help.
Try logging the value of
rangeInputto see if it is an empty jQuery object. That would make sense becausejQuery().offset().leftwould throw the error you’re getting.