lucianocosta / jquery.mtz.monthpicker

Monthpicker, the missing JQuery widget.
http://lucianocosta.com.br/jquery.mtz.monthpicker
96 stars 57 forks source link

Javascript error when input does not have "id" attribute #20

Closed ghost closed 11 years ago

ghost commented 11 years ago

When my input does not have the id attribute, the plugin does not work.

The following code uses the id attribute of input element to locate it in the line 3. This will fail if i don't have the id in my element.

show: function (n) { var widget = $('#' + this.data('monthpicker').settings.id); var monthpicker = $('#' + this.data('monthpicker').target.attr("id") + ':eq(0)'); widget.css("top", monthpicker.offset().top + monthpicker.outerHeight()); widget.css("left", monthpicker.offset().left); widget.show(); widget.find('select').focus(); this.trigger('monthpicker-show'); },

Proposed correction:

    show: function (n) {
        var widget = $('#' + this.data('monthpicker').settings.id);
        var monthpicker = $(this.data('monthpicker').target);
        widget.css("top", monthpicker.offset().top  + monthpicker.outerHeight());
        widget.css("left", monthpicker.offset().left);
        widget.show();
        widget.find('select').focus();
        this.trigger('monthpicker-show');
    },
lucianocosta commented 11 years ago

@viniciusmlimarj it was corrected some commits ago, thank you!