You are not logged in.

Announcement

Forum database was corrupt and an old backup was restored as temporary replacement. Registrations closed until the database is recovered. Please ask questions using the Contact form

#1 11-03-2014 21:37:11

oscarf
Contributors
Registered: 11-03-2014
Posts: 8

How to add accordion in tile

Hello
Is it possible to include accordion in a  tile?

I try like this bu twith no success:

[== PHP ==]
$tile[] = array("type"=>"custom","group"=>1,"x"=>0,"y"=>0,'width'=>5,'height'=>4,"background"=>"#ed1c24","url"=>"",
"content"=>
"<div class='metro-accordion'>
<h3>title1</h3>
<div> bla bla bla
</div>
<h3>title2</h3>
<div> bla bla bla
</div>
<h3>title3</h3>
<div> bla bla bla
</div>
</div>"
);

Offline

#2 12-03-2014 12:04:01

chrismaliszewski
Contributors
From: Torun, Poland
Registered: 06-05-2013
Posts: 246
Website

Re: How to add accordion in tile

This is because accordions are created during event $beforeSubPageShow. Go to plugins/accordion/plugins.js/ and search for line $.plugin($beforeSubPageShow,{ and see for yourself.

You can change this event other (list of events is here) to for example $siteLoad but I woudn't recommend it!

Instead I'd suggest you to use function createAccordions with small modiffication I made. Maybe you already have it - compare your plugin.js file of accordion with mine.
To make everything works you need to make some more changes. It won't be nice solution but the fastest one, with as a few changes as it's possible.

1. Compare your plugin.js file with my and replace differences in your code to mine.
2. In tile code add code

"classes"=>"tile-accordion"

So it'll look like this:

$tile[] = array("type"=>"custom","group"=>4,"x"=>0,"y"=>0,'width'=>5,'height'=>4,"background"=>"#ed1c24","url"=>"",
"content"=>
"<div class='metro-accordion metro-accordion-test'>
<h3>title1</h3>
<div> bla bla bla</div>
<h3>title2</h3>
<div> bla bla bla</div>
<h3>title3</h3>
<div> bla bla bla</div>
</div><script>createAccordions('test');</script>", 
"classes"=>"tile-accordion"
);

3. In plugins/accordion/plugin.js change code

$("#content, #panelContent").children(name).on("click","h3",function(){

to

$("#content, #panelContent, .tile-accordion").children(name).on("click","h3",function(){

See 3 things:
a) you need to add additional class to tile, tile-accordion or other name if you want but the same like in point 3.,
b) that you need to add additional class to div accordion (metro-accordion-test in this example),
c) the same additional name of metro-accordion (there I mean metro-accordion-test -> 'test') must be parameter for createAccordions function, in this case createAccordions('test');.

If you made all things I wrote in this and previous post, you should get working accordion inside a tile smile.

Last edited by chrismaliszewski (13-03-2014 14:10:49)

Offline

#3 12-03-2014 12:48:38

chrismaliszewski
Contributors
From: Torun, Poland
Registered: 06-05-2013
Posts: 246
Website

Re: How to add accordion in tile

To Thomas: Thomas, I think it'd like better if variable name from plugins/accordion/plugin.js should be variable which store only name of accordion like 'metro-accordion-test', not whole 'div.metro-accordion'. As default it whould be 'metro-accordion'. It'd be easier to read and change code in case of any additional problems which can occure with accordions and their names (like in this situation and my problem with panels). But it's only my suggestion smile.

Offline

#4 13-03-2014 10:46:57

oscarf
Contributors
Registered: 11-03-2014
Posts: 8

Re: How to add accordion in tile

Thanks
I make it  works as described!

Oscar

Last edited by oscarf (14-03-2014 22:27:18)

Offline

Board footer

Powered by FluxBB