Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
p0rter76 opened this issue Feb 11, 2019 · 6 comments
Open

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

p0rter76 opened this issue Feb 11, 2019 · 6 comments

Comments

@p0rter76
Copy link

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.

@KidSysco
Copy link
Owner

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;
            }

@p0rter76
Copy link
Author

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

@benjamin-albert
Copy link
Collaborator

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.

@p0rter76
Copy link
Author

p0rter76 commented Feb 12, 2019

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

@benjamin-albert
Copy link
Collaborator

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

@p0rter76
Copy link
Author

<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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants