jquery-ui-month-picker icon indicating copy to clipboard operation
jquery-ui-month-picker copied to clipboard

Error: MonthPicker can only be called on text or month inputs.

Open p0rter76 opened this issue 5 years ago • 6 comments

Hello,

I'm currently trying to implement the MonthPicker into my Java-Based Web Application but I keep getting the error message that the MonthPicker can only be called on text or month inputs even though the text box in my application has the input attribute text. I know you probably can't help with integrating this widget in a java web application but if you could give me any clue why the error keeps happening it would be great.

p0rter76 avatar Feb 11 '19 14:02 p0rter76

I will see if Benjamin wants to comment more, I think he has a strong Java background.

The code for it lives on line 358...

            var _el = this.element, _opts = this.options, _type = _el.attr('type');
            // According to http://www.w3.org/TR/html-markup/input.html#input
            // An input element with no type attribute specified represents the same thing as an
            // input element with its type attribute set to "text".
            // TLDR:
            // http://www.w3.org/TR/html5/forms.html#the-input-element
            // https://api.jquery.com/text-selector/

            // $.inArray(void 0, ['text', 'month', void 0]) returns -1 when searching for undefined in IE8 (#45)
            // This is only noticable in the real version of IE8, emulated versions
            // from the dev tools in modern browsers do not suffer from this issue.
            // if (!_el.is('input,div,span') || $.inArray(_el.attr('type'), ['text', 'month', void 0]) === -1) {
            if (!_el.is('input,div,span') || (_type !== 'text' && _type !== 'month' && _type !==  void 0)) {
                var error = _setupErr + 'MonthPicker can only be called on text or month inputs.';
                // Call alert first so that IE<10 won't trip over console.log and swallow all errors.
                alert(error + ' \n\nSee (developer tools) for more details.');

                console.error(error + '\n Caused by:');
                console.log(_el[0]);
                return false;
            }

KidSysco avatar Feb 11 '19 21:02 KidSysco

Alright thanks in advance, would be a blessing if someone else with Java experience could look into it!

p0rter76 avatar Feb 12 '19 06:02 p0rter76

This error usually means that the selector you’re using is selecting one or more elements that is not an a text or month input.

For example this snippet might be selecting some other input with type number or tel:

$('.month').MonthPickert();

If you’re still having issues please provide an example fiddle or provide JS and HTML snippets that describe how to reproduce the error.

benjamin-albert avatar Feb 12 '19 08:02 benjamin-albert

https://jsfiddle.net/ry5vL307/ The JS-File i've added to the fiddle shows the handler to register the MonthPicker in Eclipse-RAP, the control is a SWT-Text object which has the input type text but it still won't let me create the monthpicker

p0rter76 avatar Feb 12 '19 11:02 p0rter76

The HTML in the example fiddle you posted does not have any HTML element of type input. One option you can try is to convert the div that has the month text to a read only input field and crating the moth picker on that input. I’m posting from my iPhone so I can’t provide examples right now. Maybe I can provide an example sometime later

benjamin-albert avatar Feb 12 '19 13:02 benjamin-albert

<input type="text" style="position: absolute; padding: 0px 1px 0px 0px; margin: 0px; border: 0px none; background: transparent none repeat scroll 0% 0%; overflow: hidden; outline: currentcolor none medium; resize: none; -moz-appearance: none; font-family: Verdana, &quot;Lucida Sans&quot;, Arial, Helvetica, sans-serif; font-size: 14px; font-weight: normal; font-style: normal; color: rgb(74, 74, 74); width: 65px; top: 5px;" autocomplete="off">

isn't that a HTML element of type input? I'm pretty inexperienced with HTML and JS so an example would be great.

p0rter76 avatar Feb 12 '19 14:02 p0rter76