• Resolved Max Chirkov

    (@maxchirkov)


    Got really burned out today working with jQuery UI Tabs for my plugin. The worst part is that I can get all the functionality to work in 2 minutes on a blank page, but not in WordPress. Check it out – something as simple as this https://gist.github.com/1848734 – works excellent on its own, but when you put it into a plugin it will still work, but without any custom success, error or load handlers nor it will use cache as it is set in the example. Instead, WordPress, somehow “arm wrestles” my tab options into its own and switched from POST method to GET, gets rid of my cache setting as well as success/error and other events. Can’t bind some events manually either. I tried everything I could in different ways and after initializing the tabs, and at the init and right before adding new tab or loading tab content… none of that takes into effect in WordPress. It simply gets overwritten and therefore no errors shown.

    After messing with it for a couple of hours to no avail I decided to come up with a “workaround” (yey, awesome! NOT). Instead of setting up tabs options, I defined custom handler for a global method $.ajaxPrefilter(). It looks something like this:

    jQuery.ajaxPrefilter(function( options, originalOptions, jqXHR ){
        //...got direct access to all options etc just before the Ajax request is being sent.
        options.type = "POST";
        options.cache = true;
    });

    And guess what? JavaScript inspector show all options intact as they should be and, even my Ajax queries are now being submitted via POST method. The only problem – the queries are not being cached. Every time I switch between the tabs repeatedly – it sends new ajax requests. So the “workaround” finally passes the right options to the $.ajax() method, but the cache still doesn’t work.

    So, I have a few quesitons:
    1. Why the tabs() options are being overwritten by WordPress? Or what’s overwriting them?
    2. How can I make the ajax queries to be cached?

    Thanks!

Viewing 1 replies (of 1 total)
  • Thread Starter Max Chirkov

    (@maxchirkov)

    Okay. I finally pin pointed the issue. It was another plugin that was calling .tabs() on an a parent element that existed within the DOM, and that was overwriting my settings.

Viewing 1 replies (of 1 total)
  • The topic ‘jQuery UI Tabs cache and options issue in WP’ is closed to new replies.