UserX
UserX

Reputation: 1327

have different values for "active" in my jQuery accordion

Im using jQuery accordion, and it is working fine.

Im using active:0, to have my first tab open, when I acess a page.

But Im using accordion in diferent php files, like "schedule.php" and "organization.php".

And In "schedule.php" I want that my active is like I have in my script below (active:0).

But in my "organization.php", I want that my active is 1, (active:1).

Do you know how I can do this, without being repeating my script several times for each page?

$(function (){

    $('.accordion').accordion({
        active: 0,   
    });
});

Upvotes: 0

Views: 62

Answers (1)

Medhat Gayed
Medhat Gayed

Reputation: 2813

You should put your javascript code in a separate file and modify your php scripts to add a class to activate / deactivate and include your javascript file to both php files using:

<script src="/path/to/js/file.js"></script>

e.g javascript file

$(function (){

    $('.accordion.inactive').accordion({
        active: 0,   
    });
    $('.accordion.active').accordion({
        active: 1,   
    });
});

Then in schedule.php add a class inactive to your accordion div and in organization.php add a class active to your accordion div

Upvotes: 1

Related Questions