Support » Plugin: Accordion Blocks » Handler gone after Toolset AJAX refresh

  • Resolved BlushCo

    (@bmertelj)


    First, your plugin is the best!!

    1. I am using in the Toolset custom search to group search fields on the left.
    2. One feature of this search is the automatic AJAX refresh of both the output as well as the search fields panel.
    3. During the latter, it seems the accordion handler and the :after ‘+’ disappear.
    4. I have a callback function to fix this after refresh but don’t know how. I thought about reconnecting the handler to the headings, but how?
    5. I tried with .on(‘click’,’clickHandler’) but it’s ‘undefined’
    6. Thank you for your support!

    • This topic was modified 3 months, 2 weeks ago by BlushCo.

    The page I need help with: [log in to see the link]

Viewing 5 replies - 1 through 5 (of 5 total)
  • Thread Starter BlushCo

    (@bmertelj)

    1. should be “I am using accordions in the Toolset…”

    Plugin Author Phil Buchanan

    (@philbuchanan)

    I’m not sure I fully understand the issue, but this definitely sounds out of scope for the intended use.

    The only advice I can provide is that you may need to completely recreate the accordions. Basically the way the plugin works is after the initial page load, it sets up every accordion at the same time. Then it uses those created objects throughout the course of the user interactions. So if you completely replace the accordion item code, those objects disappear. This is the code in the plugin that sets up the accordions in the first place. You could try running something like this after you regenerate your accordions. Not 100% sure that will work though.

    Thread Starter BlushCo

    (@bmertelj)

    Actually, after trying your code it works.

    I just had to additionally remove the ‘no-js’ class which got added by AJAX and not restored by the accordionBlockItem(), it seems.

    Thank you!!

    Plugin Author Phil Buchanan

    (@philbuchanan)

    Glad you got it working.

    Thread Starter BlushCo

    (@bmertelj)

    Maybe to explain, Toolset is quite widely used and if you build an extensive custom search with many options and search fields you may want to group them with an accordion.

    With the option of automatic AJAX refresh these fields get overwritten and accordions disabled. I have read many reports about that.

    The Toolset support people suggest using the provided callback ‘hook’ to be used but you need the accordion’s re-initialize function for that.

    With the one you suggested this is totally possible and everything works as it should.

    
    jQuery('.js-accordion-item').each(function() {
    	jQuery(this).accordionBlockItem({
    		// Set default settings
    		initiallyOpen: jQuery(this).data('initially-open'),
    		autoClose:     jQuery(this).data('auto-close'),
    		clickToClose:  jQuery(this).data('click-to-close'),
    		scroll:        jQuery(this).data('scroll'),
    		scrollOffset:  jQuery(this).data('scroll-offset'),
    	});
            jQuery(this).removeClass('no-js');
    });

    Thanks again!

Viewing 5 replies - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.