• I noticed that I couldn’t get $.fn.almFilter to work when I passed meta_key, meta_value, and meta_compare

    So I looked at the code and found that in the $.fn.almSetFilters function, specifically on line 835 of ajax-load-more.js, you are doing a regex to clean up the shortcode parameter names. However, this regex is not catching and converting the underscores to dashes. So when I pass shortcode params that have underscores, they are being ignored by the ajax function because, for instance, it is expecting meta-key instead of meta_key. (line 341).

    I worked around this by just passing my parameter key names with the dashes instead of underscores. But this is definitely a hack and not what the documentation describes.

    Cheers.

    https://wordpress.org/plugins/ajax-load-more/

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Darren Cooney

    (@dcooney)

    You are suppose to pass data-meta-key, data-meta-compare etc. Just like the code example.

    https://connekthq.com/plugins/ajax-load-more/examples/filtering/#javascript

    Thread Starter ben_del

    (@ben_del)

    Right, but that assumes only one way of getting those parameters into the $.fn.almFilter function call. I am allowing my user to select various filters from a <select> menu and am then calling the almFilter function from within my javascript, passing those arguments dynamically. So I am not using data attributes in my HTML at all. I assumed that the key names would just match the shortcode key names. Seems to me like since you are making the $.fn.almFilter available as a public method, that you should not limit it to ONLY being useful if one chooses to use the data-attribute method. Or at least explain that in the docs more clearly. At this point, your example assumes that is the only way someone would use it.

    cheers

    Plugin Author Darren Cooney

    (@dcooney)

    Im interested to see your filters in action.

    As far as the data-* goes, yea I guess. I had not really thought about other uses. My thinking was those data attributes matched the data attributes on the #ajax-load-more div.

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘$.fn.almFilter bug when using parameters containing underscores’ is closed to new replies.