![]() |
|
Snippets |
|
This helper used JavascriptHelper. It create a div which open a another onclick with a visual effect. The content of the div is the template's result of a call to a module/action.
/** * Fonction my_div_to_remote * @author Julien Levasseur * @since - 13 sept. 07 * Extend of my_button_to_remote. return a div. * * Returns an html button to a remote action defined by 'url' (using the * 'url_for()' format) that's called in the background using XMLHttpRequest. * * See link_to_remote() for details. * */ function my_div_to_remote($name, $options = array(),$effect, $html_options = array()) { return my_div_to_function($name, $effect, remote_function($options), $html_options); } function my_div_to_function($name,$effect, $function, $html_options = array()) { $html_options = _parse_attributes($html_options); $html_options['onclick'] = $function.';'.$effect['onclickadd'].';return false;'; return content_tag('div', $name, $html_options); }
Example:
<?php echo my_div_to_remote('div de test',array('url'=>'principal/pret'),array('onclickadd' => visual_effect('toggle_blind', 'rem', array('duration' => 4.0))),array('style'=>'border: solid 1px;width:40px;height:40px;')) ?> <div id="rem" style="display:none;height:300px;border:solid 1px;">youpi</div>
If you need to call a remote function with the parameter of the changed select .
Nota for François : Could be cool to have a better documentation of remote_function.
Here is the editSuccess.php
<tr> <th> <?php echo __('Domains:') ?> </th> <td> <?php echo form_error('domain') ?> <?php echo select_tag('domain', objects_for_select( $domains, 'getIdDomain', 'getName', $list->getDomain(), 'include_custom='.__('Choose a domain')), array( 'onchange' => remote_function(array( 'update' => 'item_domain', 'url' => 'list/subdomain', 'with' => "'id=' + this.options[this.selectedIndex].value" )) ) ) ?> </td> </tr> <tr> <th> <?php echo __('Sub domains:')?> </th> <td> <?php echo form_error('sub_domain') ?> <div id="item_domain"> <?php echo select_tag('sub_domain', objects_for_select( $list_sub_domains, 'getIdDomain', 'getName', $list->getSubDomain(), 'include_custom='.__('Choose a sub domain') )) ?> </div> </td> </tr>
Here is the subdomainSuccess.php
<?php use_helper('Object') ?> <?php echo select_tag('sub_domain', objects_for_select( $list_sub_domains, 'getIdDomain', 'getName', 0, 'include_custom='.__('Choose a sub domain') )) ?>