Error in _wrapper method for numeric textbox

2 posts, 0 answers
  1. David
    David avatar
    3 posts
    Member since:
    Sep 2010

    Posted 25 Jan 2012 Link to this post

    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.
  2. Georgi Krustev
    Admin
    Georgi Krustev avatar
    3707 posts

    Posted 27 Jan 2012 Link to this post

    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!
  3. Kendo UI is VS 2017 Ready
Back to Top