Viewing 5 replies - 1 through 5 (of 5 total)
  • Are you enqueuing your accordion script correctly?

    Thread Starter nilsen

    (@nilsen)

    I am not such a great coder, this is what I found inside functions.php:

    add_shortcode('akkordeon', 'nr_shortcode_akkordeon');
    function nr_shortcode_akkordeon ($aArguments, $sInnerContent, $sShortcode) {
    
        $aArguments = nr_digest_shortcode_arguments($aArguments);
    
        global $aAkkordeonBereiche;
        $aAkkordeonBereiche = array();
        $sInnerContent = nr_process_standard_content($sInnerContent);
    
        $sAkkordeonHtml = '';
        foreach ($aAkkordeonBereiche as $aBereich) {
            $sBereichHtml = '
                <div class="na_bereich">
                    <h3 class="nas_head">' . $aBereich['aArguments']['ueberschrift'] . '</h3>
                    <div class="nas_body standard_content">' . $aBereich['sInnerContent'] . '</div>
                </div>
            ';
            $sAkkordeonHtml .= $sBereichHtml;
        }
    
        global $iAkkordeonNr;
        $iAkkordeonNr = intval($iAkkordeonNr) + 1;
        $sID = 'nat_akkordeon_' . $iAkkordeonNr;
    
        $sScript = '
            <script type="text/javascript">
                //<[CDATA[
    
                    (function () {
    
                        var oData = {};
                        oData.sNr = "' . $iAkkordeonNr . '";
                        oData.sID = "' . $sID . '";
                        oData.jAkkordeon = jQuery("#" + oData.sID);
                        oData.jAkkordeon.data("oAkkordeonData", oData);
    
                        oData.aSections = [];
                        var jSections = oData.jAkkordeon.find(".na_bereich");
                        for (var iS = 0; iS < jSections.length; iS ++) {
                            var oSection = {};
                            oSection.jSection = jSections.eq(iS);
                            oSection.jHead = oSection.jSection.find(".nas_head");
                            oSection.jBody = oSection.jSection.find(".nas_body");
                            oSection.bOpen = true;
                            oSection.open = function () {
                                this.jBody.show();
                                this.bOpen = true;
                            }
                            oSection.close = function () {
                                this.jBody.hide();
                                this.bOpen = false;
                            }
                            oSection.jHead.data("oSectionData", oSection);
                            oSection.jHead.click(function(){
                                var oSection = $(this).data("oSectionData");
                                if (oSection.bOpen) {
                                    oSection.close();
                                } else {
                                    oSection.open();
                                }
                            });
                            oSection.close();
                            oData.aSections.push(oSection);
                        }
    
                    })();
    
                //]]>
            </script>
        ';
    
        $sAkkordeonHtml = '<section id="' . $sID . '" class="nat_akkordeon">' . $sAkkordeonHtml . '</section>' . $sScript;
    
        return $sAkkordeonHtml;
    
    }

    The theme was developed especially for this website, so is this what is causing the problems and how can I enqueue the script the right way?

    Thanks!

    You need to speak to whoever created this custom theme for you.

    Thread Starter nilsen

    (@nilsen)

    Ok, I guess that would be best as well.

    Thanks for your help!

    Thread Starter nilsen

    (@nilsen)

    I fixed this by enqueing the javascript files in functions.php. There was also a problem with jquery being enqued twice, which probably caused the problem with other elements of the site when activating certain plugins.

    Thank you for pointing me in the right direction esmi 🙂

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Problem with Accordeons and Input fields when activating Plugins’ is closed to new replies.