Announcement

Collapse
No announcement yet.

'trim' of undefined

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • 'trim' of undefined

    I click create button then
    Uncaught TypeError: Cannot read property 'trim' of undefined error ?

    Detail:
    Code:
    fetch: function () {
                var data = {};
                var value = this.$element.val();
                if (this.params.trim || this.forceTrim) {
                    [COLOR=#FF0000][U]if (typeof value.trim === 'function') {[/U][/COLOR]
                        value = value.trim();
                    }
                }
                data[this.name] = value;
                return data;
            },

  • #2
    Hello,
    It also happens to me, I've fixed it by adding this:


    Code:
              
                var data = {};
                var value = this.$element.val();
    [COLOR=#008000][B]            if (value == null) {
                    value = $("input[data-name='"+this.name+"']").val()
                }[/B][/COLOR]
    
                if (this.params.trim || this.forceTrim) {
                    if (typeof value.trim === 'function') {
                        value = value.trim();
                    }
                }
    
                data[this.name] = value || null;
                return data;

    Comment

    Working...
    X