本文整理汇总了PHP中CHtml::ajaxLink方法的典型用法代码示例。如果您正苦于以下问题:PHP CHtml::ajaxLink方法的具体用法?PHP CHtml::ajaxLink怎么用?PHP CHtml::ajaxLink使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CHtml
的用法示例。
在下文中一共展示了CHtml::ajaxLink方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: reject
function reject($vcid)
{
return CHtml::ajaxLink('Reject', Yii::app()->createAbsoluteUrl('videoConference/reject/' . $vcid), array('type' => 'get', 'data' => array('id' => $vcid, 'type' => 'get'), 'update' => 'message', 'success' => 'function(response) {
$(".message").html(response);
location.reload();
}'), array('confirm' => 'Are you sure you want to reject this invitation?', 'role' => "button", "class" => "btn btn-danger"));
}
示例2: init
public function init()
{
$assetFolder = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'assets';
$publishedAssetsPath = Yii::app()->assetManager->publish($assetFolder);
if ($this->position == 'left') {
Yii::app()->clientScript->registerCssFile($publishedAssetsPath . '/css/leftsidebar.css');
Yii::app()->clientScript->registerScriptFile($publishedAssetsPath . '/js/leftsidebar.js', CClientScript::POS_END);
$js = $this->collapsed ? 'left_menu.setStartStatus(false);' : 'left_menu.setStartStatus(true);';
Yii::app()->clientScript->registerScript('leftMenu', $js, CClientScript::POS_LOAD);
echo '<div class="left_menu" id="leftmenu" style="width: 180px;">';
echo '<div class="title">';
echo CHtml::encode($this->title);
echo CHtml::ajaxLink('>>', '', false, array('id' => 'toggle_left_menu'));
echo '</div>';
} else {
Yii::app()->clientScript->registerCssFile($publishedAssetsPath . '/css/rightsidebar.css');
Yii::app()->clientScript->registerScriptFile($publishedAssetsPath . '/js/rightsidebar.js', CClientScript::POS_END);
$js = $this->collapsed ? 'right_menu.setStartStatus(false);' : 'right_menu.setStartStatus(true);';
Yii::app()->clientScript->registerScript('rightMenu', $js, CClientScript::POS_LOAD);
echo '<div class="right_menu" id="rightmenu" style="width: 180px;">';
echo '<div class="title">';
echo CHtml::encode($this->title);
echo CHtml::ajaxLink('>>', '', false, array('id' => 'toggle_right_menu'));
echo '</div>';
}
parent::init();
}
示例3: attributeToggler
/**
* attributeToggler
*
* For CGridView
*
* @param CActiveRecord $model
* @param string $attribute
* @param array $values - ("On", "Off") or ("Yes", "No") etc.
* @return CHtml::ajaxLink
*/
public static function attributeToggler($model, $attribute, $values = array('On', 'Off'))
{
if ($model->{$attribute} == 1) {
return CHtml::ajaxLink("<span class='label label-success'>" . $values[0] . "</span>", array('toggleState', 'id' => $model->id, 'attribute' => $attribute, 'value' => 0), array('success' => "reloadGrid"));
} else {
return CHtml::ajaxLink("<span class='label label-warning'>" . $values[1] . "</span>", array('toggleState', 'id' => $model->id, 'attribute' => $attribute, 'value' => 1), array('success' => "reloadGrid"));
}
}
示例4: createEditButton
function createEditButton($model, $item)
{
echo CHtml::ajaxLink(Yii::t('global', 'Edit'), array('wishlist/edititem'), array('type' => 'POST', 'dataType' => 'json', 'success' => 'js:function(data){
$("#WishlistEditForm_qty").val(data.qty);
$("#WishlistEditForm_qty_received").val(data.qty_received);
$("#WishlistEditForm_priority").val(data.priority);
$("#WishlistEditForm_comment").val(data.comment);
$("#WishlistEditForm_code").val(data.code);
$("#WishlistEditForm_id").val(data.id);
$("#WishitemEdit").dialog("open");
}', 'data' => array('code' => $model->gift_code, 'id' => $item->id)), array('id' => 'editItem' . $item->id, 'class' => 'editwish'));
}
示例5: run
public function run()
{
$val = $this->model->{$this->attribute};
if (!$this->model->isNewRecord && $val) {
$id = $this->id . get_class($this);
$files_data = $this->model->uploadFiles();
$attribute_data = $files_data[$this->attribute];
$directory = trim($attribute_data['dir'], '/');
$preview = ImageHelper::thumb($directory, $val, array('width' => null, 'height' => 128));
$preview .= CHtml::ajaxLink('X', array('/main/helpAdmin/saveAttribute'), array('type' => 'post', 'data' => array('model' => get_class($this->model), 'id' => $this->model->primaryKey, 'attribute' => $this->attribute, 'value' => '', 'unlink_file' => $directory . '/' . $val), 'success' => 'js:function() {$("#' . $id . '").remove();}'), array('class' => 'btn btn-danger delete-img'));
echo CHtml::tag('div', array('id' => $id), $preview);
}
echo CHtml::activeFileField($this->model, $this->attribute, $this->htmlOptions);
}
示例6: ajaxLink
/**
* Fixes the default yii ajaxLink with unregistering onClick Handlers first, before set new one.
*
* @param type $text
* @param type $url
* @param type $ajaxOptions
* @param type $htmlOptions
* @return type
*/
public static function ajaxLink($text, $url, $ajaxOptions = array(), $htmlOptions = array())
{
// Auto set csrf token
if (isset($ajaxOptions['data']) && is_array($ajaxOptions['data']) && !isset($ajaxOptions['data'][Yii::app()->request->csrfTokenName])) {
$ajaxOptions['data'][Yii::app()->request->csrfTokenName] = Yii::app()->request->csrfToken;
}
if (isset($htmlOptions['id'])) {
$id = $htmlOptions['id'];
$cs = Yii::app()->getClientScript();
$cs->registerScript('Yii.HHtml.#' . $id, "jQuery('body').off('click','#{$id}');");
} else {
$htmlOptions['id'] = Helpers::GetUniqeId();
}
return parent::ajaxLink($text, $url, $ajaxOptions, $htmlOptions);
}
示例7: renderContent
public function renderContent()
{
$criteria1 = new CDbCriteria(array('condition' => 'status=1'));
$all = (int) Teacher::model()->count($criteria1);
if ($all > 5) {
$offset = rand(0, $all - 5);
} else {
$offset = rand(0, $all);
}
$criteria = new CDbCriteria(array('condition' => 'status=1', 'order' => 'RAND()', 'limit' => '5,' . $offset));
//echo $all;
$teachers = Teacher::model()->findAll($criteria);
if ($teachers) {
echo CHtml::openTag("ul");
foreach ($teachers as $teacher) {
$img = '';
if ($teacher->picture) {
Yii::import('application.extensions.image.Image');
$thumbImage = new Image(Yii::getPathOfAlias('webroot') . $teacher->picture);
$img_url = $thumbImage->createThumb(70, 60);
/*$thumbImage->resize(70, 60, Image::WIDTH);
$arr = explode("/",$teacher->picture);
$file_name = $arr[count($arr)-1];
$thumb = Yii::getPathOfAlias('webroot') . '/resources/images/85x72/' . $file_name;
$thumbImage->save($thumb);*/
$img = '<img src="' . $img_url . '" />';
}
echo CHtml::openTag("li", array('class' => 'clearfix'));
echo CHtml::openTag("div", array('class' => 'avatar'));
echo CHtml::link($img, Yii::app()->createUrl('/teacher/view', array('id' => $teacher->id, 'title' => Lnt::safeTitle($teacher->name))));
echo "<div>Giảng viên</div>";
echo CHtml::closeTag("div");
echo CHtml::openTag("div", array('class' => 'title'));
echo CHtml::link($teacher->name, Yii::app()->createUrl('/teacher/view', array('id' => $teacher->id, 'title' => Lnt::safeTitle($teacher->name))));
echo CHtml::closeTag("div");
echo CHtml::openTag("div", array('style' => 'margin-top:10px;float:left;width:80px;height:14px;background:#ce1f46;color:#fff;padding:8px 0px;text-align:center'));
echo "5.1232";
echo CHtml::closeTag("div");
echo CHtml::openTag("div", array('style' => 'float:right;text-align:left;width:127px;margin-top:10px;font-weight:bold;color:#a8a8a8;'));
echo $teacher->videoCount . " bài giảng | " . $teacher->likeTeachersCount . " " . CHtml::ajaxLink(CHtml::image(Yii::app()->baseUrl . '/images/tim_03.jpg', 'Like', array('title' => 'Yêu thích')), Yii::app()->createUrl('/teacher/like', array('id' => $teacher->id)), array('success' => 'js:function(res){alert(res.msg);}'), array('class' => 'teacher_like'));
echo CHtml::closeTag("div");
echo CHtml::closeTag("li");
}
echo CHtml::closeTag("ul");
}
}
示例8: renderItemstyle
/**
* render buttons to style clistviewitems, like square or list
*/
public function renderItemstyle()
{
$class = '';
if (Yii::app()->session->get('view', 'list') == 'list') {
$class = $this->class;
}
echo CHtml::ajaxLink('<i class="prod_list_style"></i>', Yii::app()->createUrl('ajax/changeView'), array('data' => array('type' => 'list'), 'method' => 'POST', 'complete' => 'function() {
$.fn.yiiListView.update("catalog-products");
$("#list").addClass("active");
$("#square").removeClass("active");
}'), array('class' => $class, 'id' => 'list'));
$class = '';
if (Yii::app()->session->get('view', 'list') == 'square') {
$class = $this->class;
}
echo CHtml::ajaxLink('<i class="prod_cards_style"></i>', Yii::app()->createUrl('ajax/changeView'), array('data' => array('type' => 'square'), 'method' => 'POST', 'complete' => 'function() {
$.fn.yiiListView.update("catalog-products");
$("#square").addClass("active");
$("#list").removeClass("active");
}'), array('class' => $class, 'id' => 'square'));
}
示例9: renderMenuItem
/**
* @see CMenu::renderMenuItem()
*/
protected function renderMenuItem($item) {
// raise the item counter
$this->_itemCounter++;
if (isset($item['url'])) {
// sets the link label
$label = $this->linkLabelWrapper === null ? $item['label'] : '<' . $this->linkLabelWrapper . '>' . $item['label'] . '</' . $this->linkLabelWrapper . '>';
// creates the ajax link
if (($this->ajax && (!isset($item['ajax']) || (isset($item['ajax']) && $item['ajax'] !== false))) || (isset($item['ajax']) && $item['ajax'])) {
// set the new id if randomID is true
if ($this->randomID)
$item['linkOptions']['id'] = isset($item['linkOptions']['id']) ? $item['linkOptions']['id'] . rand() : 'am' . uniqid();
else
$item['linkOptions']['id'] = isset($item['linkOptions']['id']) ? $item['linkOptions']['id'] : 'am-' . $this->_itemCounter;
// set the ajax options
$ajax = isset($item['ajax']) ? $item['ajax'] : $this->ajax;
$ajax_options = $ajax;
if (isset($ajax['success']) == FALSE){
if (isset($ajax['update']))
$jquery_method = '$("' . $ajax['update'] . '").html(data);';
elseif (isset($ajax['replace']))
$jquery_method = '$("' . $ajax['replace'] . '").replaceWith(data);';
else
$jquery_method = NULL;
$ajax_options['success'] =
'js: function(data) { $("#' . $this->id . ' li").removeClass("' . $this->activeCssClass . '");
$("#' . $item['linkOptions']['id'] . '").parent().addClass("' . $this->activeCssClass . '");' .
$jquery_method . ' }';
}
// creates the ajax link. $item['linkOptions'] should come 2nd in the array_merge.
$linkHtmlOptions = (isset($item['linkOptions']) ? array_merge(array('live'=>false), $item['linkOptions']) : array('live'=>false));
return CHtml::ajaxLink($label, $item['url'], $ajax_options, $linkHtmlOptions);
} else
return CHtml::link($label, $item['url'], isset($item['linkOptions']) ? $item['linkOptions'] : array());
}
else
return CHtml::tag('span', isset($item['linkOptions']) ? $item['linkOptions'] : array(), $item['label']);
}
示例10: array
</td>
<td rowspan="2" class="withborder">
<p>
<?php
echo CHtml::link('Tyhjennä muokkaustila', array('image/basketDelete'), array('class' => 'linkbutton', 'confirm' => 'Poistetaanko kuvat kuvien muokkaustilasta?'));
?>
</p>
<br />
<br />
<br />
<br />
<br />
<p>
<?php
echo CHtml::ajaxLink('Sijoita kaikkiin kuviin', array('image/fastSave'), array('type' => 'POST'), array('class' => 'linkbutton', 'confirm' => 'Sijoitetaanko syötetty metadata kaikkiin kuviin?'));
?>
</p>
</td>
</tr>
<tr>
<td class="withborder">
<div class="row">
<?php
echo CHtml::activeLabel($model, 'valokuvaaja');
?>
<br />
<?php
示例11: array
<li class="address-block address-block-pickable">
<p class="webstore-label">
<?php
echo $objAddress->formattedblockcountry;
?>
<span class="controls">
<?php
echo CHtml::link(Yii::t('checkout', 'Edit Address'), Yii::app()->createUrl('/checkout/editaddress', array('id' => $objAddress->id, 'type' => 'billing')));
?>
<?php
echo Yii::t('checkout', 'or');
?>
<?php
echo CHtml::ajaxLink(Yii::t('checkout', 'Remove'), Yii::app()->createUrl('myaccount/removeaddress'), array('type' => 'POST', 'data' => array('CustomerAddressId' => $objAddress->id, 'YII_CSRF_TOKEN' => Yii::app()->request->csrfToken), 'success' => 'function(data) {
var addressBlock = $(this).parents(".address-block")[0];
$(addressBlock).remove();
}.bind(this)'), array('class' => 'delete'));
?>
</span>
</p>
<div class="buttons">
<?php
echo CHtml::htmlButton(Yii::t('checkout', $objAddress->id == $model->intShippingAddress ? 'Use shipping address' : 'Use this address'), array('type' => 'submit', 'class' => $objAddress->id == $model->intBillingAddress ? 'small default' : 'small', 'name' => 'BillingAddress', 'id' => 'BillingAddress', 'onclick' => '$("form").removeClass("error").end().find(".required").remove().end().find(".form-error").remove().end()', 'value' => $objAddress->id));
?>
</div>
</li>
<?php
}
?>
<?php
}
示例12: array
<li>
<?php
echo CHtml::ajaxLink(Yii::t('timetable', 'Set Timetable') . '<span>' . Yii::t('timetable', 'Timetable For The Batch') . '</span>', array('/site/explorer', 'widget' => '2', 'rurl' => 'timetable/weekdays/timetable'), array('update' => '#explorer_handler'), array('id' => 'explorer_timetable', 'class' => 'sbook_ico', 'active' => Yii::app()->controller->id == 'weekdays'));
?>
</li>
<li>
<?php
echo CHtml::ajaxLink(Yii::t('timetable', 'Set Weekdays') . '<span>' . Yii::t('timetable', 'Weekdays For The Batch') . '</span>', array('/site/explorer', 'widget' => '2', 'rurl' => 'timetable/weekdays'), array('update' => '#explorer_handler'), array('id' => 'explorer_weekdays', 'class' => 'lbook_ico', 'active' => Yii::app()->controller->id == 'weekdays'));
?>
</li>
<li>
<?php
echo CHtml::ajaxLink(Yii::t('timetable', 'Set Class Timing') . '<span>' . Yii::t('timetable', 'Class Timing For The Batch') . '</span>', array('/site/explorer', 'widget' => '2', 'rurl' => 'timetable/classTiming'), array('update' => '#explorer_handler'), array('id' => 'explorer_classTiming', 'class' => 'abook_ico', 'active' => Yii::app()->controller->id == 'classTiming'));
?>
</li>
<?php
if (Yii::app()->controller->id == 'weekdays') {
?>
<li class="list_active">
<?php
echo CHtml::link(Yii::t('timetable', 'Set Default Weekdays') . '<span>' . Yii::t('timetable', 'Default Weekdays For The Institution') . '</span>', array('/timetable/weekdays', 'type' => 'default'), array('class' => 'abook_ico'));
?>
</li>
<?php
} else {
?>
<li>
示例13: createButton
/**
* Creates the button element.
* @return string the created button.
*/
protected function createButton()
{
switch ($this->buttonType) {
case self::BUTTON_BUTTON:
return CHtml::htmlButton($this->label, $this->htmlOptions);
case self::BUTTON_SUBMIT:
$this->htmlOptions['type'] = 'submit';
return CHtml::htmlButton($this->label, $this->htmlOptions);
case self::BUTTON_RESET:
$this->htmlOptions['type'] = 'reset';
return CHtml::htmlButton($this->label, $this->htmlOptions);
case self::BUTTON_SUBMITLINK:
return CHtml::linkButton($this->label, $this->htmlOptions);
case self::BUTTON_AJAXLINK:
return CHtml::ajaxLink($this->label, $this->url, $this->ajaxOptions, $this->htmlOptions);
case self::BUTTON_AJAXBUTTON:
$this->ajaxOptions['url'] = $this->url;
$this->htmlOptions['ajax'] = $this->ajaxOptions;
return CHtml::htmlButton($this->label, $this->htmlOptions);
case self::BUTTON_AJAXSUBMIT:
$this->ajaxOptions['type'] = 'POST';
$this->ajaxOptions['url'] = $this->url;
$this->htmlOptions['type'] = 'submit';
$this->htmlOptions['ajax'] = $this->ajaxOptions;
return CHtml::htmlButton($this->label, $this->htmlOptions);
default:
case self::BUTTON_LINK:
return CHtml::link($this->label, $this->url, $this->htmlOptions);
}
}
示例14: ajaxDialog
private function ajaxDialog($label, $url, $title = null, $type = 'link', $ajaxOptions = array())
{
$id = self::ID . '-dialog';
$ajaxOptions = array_merge(array('update' => '#' . $id, 'type' => 'post', 'complete' => "function(){ \$('#{$id}').dialog('option', 'position', 'center').dialog('open');}"), $ajaxOptions);
$url = Yii::app()->getController()->createUrl($url);
if ($type === 'button') {
$content = CHtml::ajaxButton($label, $url, $ajaxOptions);
} else {
$content = CHtml::ajaxLink($label, $url, $ajaxOptions);
}
$content .= Yii::app()->getController()->widget('zii.widgets.jui.CJuiDialog', array('options' => array_merge($this->dialogOptions, array('title' => $title)), 'id' => $id), true);
return $content;
}
示例15: array
/**
* Created by PhpStorm.
* User: Admin
* Date: 21.08.14
* Time: 16:03
*/
?>
<section class="postOneBloger">
<?= CHtml::link(Yii::t('main', 'Редагувати'), array('/blog/cabinet/update', 'id'=>$data->id)); ?>
<?= CHtml::ajaxLink(Yii::t('main', 'Видалити'), array('/blog/cabinet/delete', 'id'=>$data->id),
array(
//'update'=>'#req_res_loading',
'beforeSend' => 'function() {
$("#maindiv").addClass("loading");
}',
'complete'=>'function(data){
$.fn.yiiListView.update("userList");
}',
),
array('confirm' => Yii::t('main', 'Ви дійсно хочете видалити пост?'), 'id'=>'post_id_'.$data->id,
)); ?>
<p>
<i class="fa fa-bookmark "></i>
<?= CHtml::link($data->title, array('/blog/default/post', 'id'=>$data->id)); ?>
<?= CHtml::link('Автор: '.$data->author->name, array('/blog/default/bloger', 'id'=>$data->author->id)); ?>
</p>
</section>