JQuery UI accordion on repeater

Post any questions you have about using the Verj.io Studio, including client and server-side programming with Javascript or FPL, and integration with databases, web services etc.

Moderators: Jon, Steve, Ian, Dave

Steve James
Ebase User
Posts: 331
Joined: Mon Mar 10, 2014 8:34 am

JQuery UI accordion on repeater

#1

Postby Steve James » Tue Aug 23, 2016 8:59 am

Hi, I'm struggling to get an accordion to work on a repeater.

JQuery is treating each record in pairs, ie
row 1 = title
row 2 = content
row 3 = title
row 4 = content
row 5 = title
row 6 = content

Any suggestions / samples of this working?

thanks
0 x

Jon
Moderator
Moderator
Posts: 1342
Joined: Wed Sep 12, 2007 12:49 pm

#2

Postby Jon » Tue Aug 23, 2016 11:34 am

I don't have any examples of using an accordion with a repeater, the general feeling is that it is difficult because of the jquery implementation.

The server admin application has a few examples of dynamically opening/closing panels within a repeater, but it uses jquery slideToggle() instead. Here are extracts from the code:

Each repeater row contains a header panel and a content panel like this.

Repeater
--RepeaterRow (with class "openableContent")
----Panel (Header panel with class "logsHeader")
------Header content
----Panel (Content panel with class "openableDetail")
------Row content

The header panel has a jquery click event:
togglePanelVisibility($(this), ".openablecontent", ".openabledetail");

Here's the togglePanelVisibility function:

Code: Select all

function togglePanelVisibility(headerElement, parentClass, contentClass)
{
	var content = headerElement.closest(parentClass).find(contentClass);
	content.slideToggle();
}
For info, the header panel also has mouseenter and mouseleave events to set the cursor:

mouseenter: $(this).css("cursor","pointer");
mouseleave: $(this).css("cursor","auto");

If you want to use an accordion, other suggestions would be to use a Custom Layout or an HTML Control so you have more control of the generated HTML.
0 x

Steve James
Ebase User
Posts: 331
Joined: Mon Mar 10, 2014 8:34 am

#3

Postby Steve James » Tue Aug 23, 2016 11:49 am

Thanks Jon, I'll have a look at slideToggle as that look just the ticket.

Steve
0 x


Who is online

Users browsing this forum: No registered users and 7 guests