I'm using PrimeFaces 3.4 collapsible panels. The problem with actual solution is that panel is toggled via clicking in small button on the right. It is not very ergonomic and the user would expect the toggling via clicking anywhere on header.
This is what I want to implement: trigger the toggle via clicking on header and remove the toggle button. This is what I've written:
$('.ui-panel-titlebar').each(function(){
var header = $(this);
var widgetId = 'widget_' + header.attr('id').replace(/:/g, '_').replace(/_header$/, '');
header.css('cursor', 'pointer');
var toggler = header.find('a[id$=_toggler]');
toggler.remove();
header.click(function(){
window[widgetId].toggle();
});
});
But I don't like that solution, because first I'm guessing the JavaScript widget Id, and second, I'm removing the rendered toggle button from DOM tree and I would prefer it not to be rendered at all.
Is there a way to achieve the same effect in more elegant way without writing too many code (so, without rewriting the p:panel
)? Using extensions based on same licence as PrimeFaces (commerce-friendly) is acceptable as solution.