New Helper for sfJqueryReloadedPlugin

14 views
Skip to first unread message

Rajesh Meniya

unread,
Jun 19, 2010, 2:56:09 AM6/19/10
to sfJqueryReloadedPlugin
New helper 'jq_show_hide_switch' for sfJqueryReloadedPlugin.
This new helper useful to create toggle switch for toggle any element
in the page.

code of this helper:
//------------------------------------------------------------
function jq_show_hide_switch($element_id=null, $plus="+", $minus="-")
{
if( !is_null($element_id) )
{
return sprintf("<a href='#' onclick='jQuery(\"#%s
\").toggle();jQuery(\"#p_%s\").toggle();" .
"jQuery(\"#m_%s\").toggle();'>" .
"<span id='p_%s'>%s</span>" .
"<span id='m_%s' style='display:none;'>%s</span>".
"</a>",$element_id, $element_id, $element_id, $element_id, $plus,
$element_id, $minus);
}else{
return false;
}
}
//--------------------------------------------------------------

Tom Boutell

unread,
Jul 9, 2010, 12:30:07 PM7/9/10
to sfJqueryReloadedPlugin
sfJqueryReloadedPlugin is intended as a jQuery reimplementation of the
classic Symfony 1.0 Prototype helpers. The feature you're proposing is
better implemented as a JavaScript function, in my opinion.

Here at P'unk Avenue we're looking at migrating away from the helpers
as much as possible and toward "writing JavaScript in JavaScript," as
Fabien now recommends. So I would prefer not to see new helpers that
are not intended as ports of the traditional ones for those who
haven't had a chance to rewrite code to just use $.post() directly,
etc. Writing your own jQuery code is not really any more verbose
(although I wish "json_encode()" had a few less characters in it), and
the end result is more easily debugged and enhanced.

Of course, we're not the only people who use the plugin. I'm
interested to hear the thoughts of others in the group.
Reply all
Reply to author
Forward
0 new messages