本文整理汇总了PHP中JavaScriptHelper::event方法的典型用法代码示例。如果您正苦于以下问题:PHP JavaScriptHelper::event方法的具体用法?PHP JavaScriptHelper::event怎么用?PHP JavaScriptHelper::event使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JavaScriptHelper
的用法示例。
在下文中一共展示了JavaScriptHelper::event方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: observeForm
/**
* Observe entire form and call ajax on change.
*
* Like @see observeField(), but operates on an entire form identified by the
* DOM ID <b>form</b>. <b>options</b> are the same as <b>observeField</b>, except
* the default value of the <i>with</i> option evaluates to the
* serialized (request string) value of the form.
*
* @param string $form DOM ID of form to observe
* @param array $options ajax options
* @return string ajax script
*/
function observeForm($form, $options = array()) {
if (!isset($options['with'])) {
$options['with'] = "$('#$form').serialize()";
}
$callback = $this->remoteFunction($options);
return $this->Javascript->event("'#{$form} input, #{$form} select, #{$form} textarea'", "change", $callback);
}
示例2: submit
/**
* Returns a button input tag that will submit using Ajax
*
* Returns a button input tag that will submit form using XMLHttpRequest in the background instead
* of regular reloading POST arrangement. <i>options</i> argument is the same as
* in AjaxHelper::form().
*
* @param string $title Input button title
* @param array $options Callback options
* @return string Ajaxed input button
* @see AjaxHelper::form()
* @link http://book.cakephp.org/1.3/en/The-Manual/Core-Helpers/AJAX.html#submit
*/
function submit($title = 'Submit', $options = array())
{
$htmlOptions = $this->__getHtmlOptions($options);
$htmlOptions['value'] = $title;
if (!isset($options['with'])) {
$options['with'] = 'Form.serialize(Event.element(event).form)';
}
if (!isset($htmlOptions['id'])) {
$htmlOptions['id'] = 'submit' . intval(mt_rand());
}
$htmlOptions['onclick'] = "event.returnValue = false; return false;";
$callback = $this->remoteFunction($options);
$form = $this->Form->submit($title, $htmlOptions);
$script = $this->Javascript->event('"' . $htmlOptions['id'] . '"', 'click', $callback);
return $form . $script;
}