Changeset 8451
- Timestamp:
- 04/14/08 17:06:16 (1 year ago)
- Files:
-
- branches/1.1/lib/helper/JavascriptHelper.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/1.1/lib/helper/JavascriptHelper.php
r8395 r8451 82 82 * Examples: 83 83 * <?php echo link_to_function('Greeting', "alert('Hello world!')") ?> 84 * <?php echo link_to_function(image_tag('delete'), " if confirm('Really?'){ do_delete(); }") ?>84 * <?php echo link_to_function(image_tag('delete'), "do_delete()", array('confirm' => 'Really?')) ?> 85 85 */ 86 86 function link_to_function($name, $function, $html_options = array()) … … 89 89 90 90 $html_options['href'] = isset($html_options['href']) ? $html_options['href'] : '#'; 91 $html_options['onclick'] = $function.'; return false;'; 91 if ( isset($html_options['confirm']) ) 92 { 93 $confirm = escape_javascript($html_options['confirm']); 94 $html_options['onclick'] = "if(confirm('$confirm')){ $function;}; return false;"; 95 } 96 else 97 { 98 $html_options['onclick'] = $function.'; return false;'; 99 } 92 100 93 101 return content_tag('a', $name, $html_options);

