RT# 82949 - changes section name from fees to pricing, better opiton
[freeside.git] / httemplate / elements / link-replace_element_text.html
1 <%doc>
2
3 Display a link with javascript to replace text within a element.
4
5 Usage:
6
7 <& /elements/link-replace_element_text.html, {
8       target_id    => 'input_id',
9       replace_text => 'hello',
10
11       element_type => 'input', # Uses jquery val()  method to replace text
12       element_type => 'div',   # Uses jquery text() method to replace text
13
14       href  => ...
15       style => ...
16       class => ...
17    }
18 &>
19
20 </%doc>
21 <a href="<% $param{href} %>"
22    style="<% $param{style} %>"
23 % if ($param{class}) {
24    class="<% $param{class} %>"
25 % }
26    onClick="$('#<% $param{target_id} %>').<% $param{jmethod} %>('<% $param{replace_text} |h %>');"><% $param{link_text} %></a>
27 <%init>
28
29 die "template call requires a parameter hashref" unless ref $_[0];
30
31 # Defaults that can be overridden in param hashref
32 my %param = (
33     target_id    => 'SPECIFY_AN_INPUT_ELEMENT_ID',
34     replace_text => 'REPLACEMENT_TEXT_FOR_INPUT_ELEMENT',
35     element_type => 'input',
36
37     link_text    => qq{<img src="${fsurl}images/eye-20x20.png" height="14" width="14">},
38     href         => 'javascript:void(0)',
39     style        => 'text-decoration:none;',
40     class        => undef,
41
42     %{ $_[0] },
43 );
44 $param{jmethod} = $param{element_type} eq 'input' ? 'val' : 'text';
45 </%init>