Reputation: 3264
I have this code:
$(acc_id).accordion({
alwaysOpen: false,
active: false,
autoheight: false,
header: 'h3.ui-accordion3-header',
clearStyle: true
});
I want to send a variable to it, since the header should be unique.
Upvotes: 0
Views: 709
Reputation: 78272
var header = 'h3.ui-accordion3-header';
$(acc_id).accordion({
alwaysOpen: false,
active: false,
autoheight: false,
header: header,
clearStyle: true
});
Upvotes: 2
Reputation: 51052
The approach given in the examples by ChaosPandion and rochal (where the header is defined from a variable) seems best to me, but another useful thing to know about is that you can redefine any option on an accordion by using the "option" option, like this:
$(acc_id).accordion({
alwaysOpen: false,
active: false,
autoheight: false,
header: 'placeholder',
clearStyle: true
});
$(acc_id).accordion('option', 'header', 'h3.ui-accordion3-header');
In this way you can create the accordion and then, afterwards, set the header value.
Upvotes: 1
Reputation: 76918
Not totally sure what you're looking for, but something like this may work
$(acc_id).accordion({
alwaysOpen: false,
active: false,
autoheight: false,
header: $(this).find('h3.ui-accordion3-header').text(),
clearStyle: true
});
Upvotes: 0
Reputation: 7781
Try:
function Accord(acc_id, header_id) {
$('#' + acc_id).accordion({
alwaysOpen: false,
active: false,
autoheight: false,
header: header_id,
clearStyle: true
});
}
Upvotes: 0