This is a migrated thread and some comments may be shown as answers.

Error in _wrapper method for numeric textbox

1 Answer 114 Views
NumericTextBox
This is a migrated thread and some comments may be shown as answers.
David
Top achievements
Rank 1
David asked on 26 Jan 2012, 12:06 AM
The _wrapper method in the  NumericTextbox looks like it has a bug where there is unreachable code, if the NumericTextbox  
has been loaded previously.

Looking at the source and comparing it to the DatePicker source, which I know works, I can see the problem.

The source for DatePicker has this definition:
_wrapper: function() {
            var that = this,
                element = that.element,
                wrapper;
 
            wrapper = element.parents(".k-datepicker");
 
            if (!wrapper[0]) {
                wrapper = element.wrap(SPAN).parent().addClass("k-picker-wrap k-state-default");
                wrapper = wrapper.wrap(SPAN).parent();
            }
 
            wrapper[0].style.cssText = element[0].style.cssText;
            element.css({
                width: "100%",
                height: "auto"
            });
 
            that.wrapper = wrapper.addClass("k-widget k-datepicker k-header");
            that._inputWrapper = $(wrapper[0].firstChild);
        }

The source for NumericTextbox has this definition:
_wrapper: function() {
            var that = this,
                element = that.element,
                wrapper;
 
            wrapper = element.parent();
 
            if (!wrapper.is("span.k-widget")) {
                wrapper = element.hide().wrap('<span class="k-numeric-wrap k-state-default" />').parent();
                wrapper = wrapper.wrap("<span/>").parent();
            }
 
            wrapper[0].style.cssText = element[0].style.cssText;
            that.wrapper = wrapper.addClass("k-widget k-numerictextbox").show();
            that._inputWrapper = $(wrapper[0].firstChild);
        }

You may note that it only looks at the direct parent for the wrapper, when in fact the wrapper is on it's second parent, as indicated by last half of the code.

Also this bug may be replicated on http://demos.kendoui.com/web/numerictextbox/index.html by simply rerunning the command through a browser console
$("#numeric").kendoNumericTextBox();

If the code is supposed to be rerun-able then it should look similar to the following:
wrapper = element.parents('.k-numerictextbox');
  
if (!wrapper.is(".k-numerictextbox")) {
    wrapper = element.hide().wrap('<span class="k-numeric-wrap k-state-default" />').parent();
    wrapper = wrapper.wrap("<span/>").parent();
}


Now I don't know if the Kendo UI elements are all supposed to be rerun-able or not, I will post a separate thread about that as that is a more generic conversation.

1 Answer, 1 is accepted

Sort by
0
Georgi Krustev
Telerik team
answered on 27 Jan 2012, 09:15 AM
Hello David,

 
Currently the KendoUI widgets are not intended to be initiliazed numerious times. Nevertheless, we will fix the reported issue. As to the required functionality, I will forward your request to our developers for further investigation.

All the best,
Georgi Krustev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
NumericTextBox
Asked by
David
Top achievements
Rank 1
Answers by
Georgi Krustev
Telerik team
Share this question
or