germanysbestkeptsecret / Wookmark-jQuery

A jQuery plugin to create a dynamic, multi-column layout.
MIT License
2.63k stars 759 forks source link

Error: a[s].push is not a function #142

Closed jgiovanni closed 10 years ago

jgiovanni commented 10 years ago

I don't know if anyone else is having this error when initiating the wookmark plugin, but this may be of some use...

I got this error while using Firefox, but it works in Chrome, haven't tested IE. In Firefox it was not creating the nested object before pushing the DOMelement into the object array for the updateFilterClasses function.

basically I changed this:

return s.prototype.updateFilterClasses = function() {
        for (var t, i, s, h, o = 0, n = 0, r = 0, a = {}, l = this.possibleFilters; this.handler.length > o; o++)
        if (i = this.handler.eq(o), t = i.data("filterClass"), "object" == typeof t && t.length > 0)
            for (n = 0; t.length > n; n++)
            s = e(t[n]), a[s] || (a[s] = []), a[s].push(i[0]);
        for (; l.length > r; r++)
        h = e(l[r]), h in a || (a[h] = []);
        this.filterClasses = a
    }

To:

return s.prototype.updateFilterClasses = function() {
        for (var t, i, s, h, o = 0, n = 0, r = 0, a = {}, l = this.possibleFilters; this.handler.length > o; o++)
        if (i = this.handler.eq(o), t = i.data("filterClass"), "object" == typeof t && t.length > 0)
            for (n = 0; t.length > n; n++)
            s = e(t[n]), typeof a[s] === 'undefined' || typeof a[s][0] === 'undefined' ? a[s] = [] : a[s], a[s].push(i[0]);
        for (; l.length > r; r++)
        h = e(l[r]), h in a || (a[h] = []);
        this.filterClasses = a;
    }
Sebobo commented 10 years ago

Hi,

I think it would have been easier do modify the unminified readable version. Would be nice if you could do that and create a pull request.

Regards