Richard Searle

home

Controlling jquery tab plugin add

04 Jul 2011

The jquery tab plugin provides a means to dynamically add a tab, but without any evident mechanism to determine the id of the tab. My use case required the population of that panel using Lift  AJAX, which requires the id to identify the  html element to be modified. Only the tabTemplate accepts parameters, so that mechanism does not suffice. The template mechanism is now depreciated, which would eliminate it from consideration even if the the panelTemplate accepted parameters. The assigned id turns out to be the fragment id iff a fragment URL is specified on the add call. Specifying a full URL causes a sequential, jquery generated id to be assigned. Dynamically creating the tab and populating can thus be done using
JsRaw("$('#tabs').tabs( 'add', '#" + id + "', 'title' )") &
SetHtml(id, Id is{id})