当前位置: 首页>>代码示例>>PHP>>正文


PHP CHtml::ajax方法代码示例

本文整理汇总了PHP中CHtml::ajax方法的典型用法代码示例。如果您正苦于以下问题:PHP CHtml::ajax方法的具体用法?PHP CHtml::ajax怎么用?PHP CHtml::ajax使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CHtml的用法示例。


在下文中一共展示了CHtml::ajax方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: initColumn

    protected function initColumn()
    {
        $collection = new DaActiveRecordCollection($this->grid->dataProvider->getData());
        $idObject = $this->getObject()->id_object;
        foreach ($collection as $key => $obj) {
            if (!Yii::app()->authManager->checkObjectInstance(DaDbAuthManager::OPERATION_DELETE, Yii::app()->user->id, $idObject, $key, false)) {
                $collection->remove($key);
            } else {
                $this->_availableIdInstance[] = $key;
            }
        }
        if ($collection->getCount() == 0) {
            $this->visible = false;
            return;
        }
        $info = $this->grid->dataProvider->model->isInstancesAvailableForDelete($collection);
        foreach ($info as $id => $availableInfo) {
            if (!$availableInfo['result']) {
                $key = array_search($id, $this->_availableIdInstance);
                unset($this->_availableIdInstance[$key]);
                $this->_unavailableInfo[$id] = implode(', ', $availableInfo['info']);
            }
        }
        $js = 'function da_deleteRecord(idObject, idInstance) {
  ' . CHtml::ajax(array('type' => 'POST', 'dataType' => 'json', 'url' => Yii::app()->createUrl('backend/ygin/deleteRecord'), 'data' => 'js:{idObject:idObject, idInstance:idInstance}', 'success' => 'function(data){
  if (data.error !== undefined) {$.daSticker({text:data.error, type:"error", sticked:true}); $("#ygin_inst_" + data.idInstance + " .action-delete a").removeClass("process"); return;}
  $.daSticker({text:data.message, type:"success"});
  $("#ygin_inst_" + data.idInstance).remove();
  if ($(".b-instance-list tbody tr").length == 0) {$(".b-instance-list, .b-instance-list-count").remove();}
}')) . '
}';
        Yii::app()->clientScript->registerScript('admin.delete-record-ajax', $js, CClientScript::POS_HEAD);
    }
开发者ID:kot-ezhva,项目名称:ygin,代码行数:33,代码来源:ActionDeleteColumn.php

示例2: updatePriorityAjax

 protected function updatePriorityAjax($model_id, $dir, $update)
 {
     $url = array('/' . $this->getOwner()->getRoute());
     $data = $_GET;
     $data['direction'] = $dir;
     $data['model_id'] = $model_id;
     return CHtml::ajax(array('update' => $update, 'url' => $url, 'type' => 'get', 'data' => $data));
 }
开发者ID:hit-shappens,项目名称:testapp,代码行数:8,代码来源:OrderBehavior.php

示例3: registerAssignScript

    /**
     *
     * @param CActiveRecord $model
     * @param int $id
     * @param array $config 
     */
    public function registerAssignScript($model, $id, array $config = array())
    {
        Yii::app()->controller->beginWidget('zii.widgets.jui.CJuiDialog', array('id' => 'assignDriver', "options" => array('title' => 'Assign Driver', 'autoOpen' => false, 'modal' => true, 'buttons' => array('Close' => 'js:function(){$(this).dialog("close")}', 'Assign' => 'js:function(){' . CHtml::ajax(array('url' => $config['ajaxUrl'], 'type' => 'post', 'dataType' => 'json', 'data' => 'js:$("#assignDriver form").serialize()', 'success' => 'function(r){if(r.success){
					$("#assignDriver").dialog("close");
					$.fn.yiiGridView.update("tracking-grid");
				}; 
				if(!r.success){alert("Gagal assign driver")}}')) . ';}'))), true);
        $driverForm = new CForm(array('elements' => array('driver' => array('type' => 'dropdownlist', 'items' => OrderTracking::getDriverList()), 'id' => array('type' => 'hidden'))), $model);
        echo $driverForm->render();
        Yii::app()->controller->endWidget();
        Yii::app()->clientScript->registerScript($id, "jQuery('body').undelegate('.assignDriver_button','click').delegate('.assignDriver_button','click',function(){\ndriverDialog=jQuery('#assignDriver');\ndriverDialog.dialog('open');\njQuery('#assignDriver input#OrderTracking_id').val(\$(this).attr('rel').replace('grid.',''));\n\treturn false;\n});\t");
    }
开发者ID:aantonw,项目名称:dcourier.system,代码行数:18,代码来源:CTrackOrder.php

示例4: init

    public function init()
    {
        $data = $this->grid->dataProvider->getData();
        if (count($data) == 0) {
            return;
        }
        $userId = Yii::app()->user->id;
        $idObject = $this->object->id_object;
        $idObjectParameter = $this->objectParameter->getIdParameter();
        $ok = false;
        foreach ($data as $instance) {
            $idInstance = $instance->getIdInstance();
            if (Yii::app()->authManager->checkObjectParameter($userId, $idObject, $idInstance, $idObjectParameter)) {
                $this->_permission[$idInstance] = true;
                $ok = true;
            } else {
                $this->_permission[$idInstance] = false;
            }
        }
        if (!$ok) {
            return;
        }
        Yii::app()->controller->registerJsFile('ygin_visual_element.js', 'backend.assets.js');
        $js = 'function da_booleanColumn(idInstance, idObject, idObjectParameter) {
  ' . CHtml::ajax(array('type' => 'POST', 'dataType' => 'json', 'url' => Yii::app()->createUrl('backend/ygin/booleanColumn'), 'data' => 'js:{idObject:idObject, idInstance:idInstance, idObjectParameter:idObjectParameter}', 'success' => 'function(data){
  if (data.error !== undefined) {
    $.daSticker({text:data.error, type:"error", sticked:true});
  } else {
    $.daSticker({text:data.message, type:"success"});
  }
  newClass = "glyphicon glyphicon-remove icon-red editable";
  if (data.value == 1) newClass = "glyphicon glyphicon-ok icon-green editable";
  $("#bool_" + data.idInstance + "_" + data.idObjectParameter).removeClass().addClass(newClass);
}')) . '
}';
        Yii::app()->clientScript->registerScript('admin.booleanColumn-ajax', $js, CClientScript::POS_HEAD);
    }
开发者ID:Cranky4,项目名称:npfs,代码行数:37,代码来源:BooleanColumn.php

示例5: testAjaxCallbacks

 public function testAjaxCallbacks()
 {
     $out = CHtml::ajax(array('success' => 'js:function() { /* callback */ }'));
     $this->assertTrue(mb_strpos($out, "'success':function() { /* callback */ }", null, Yii::app()->charset) !== false, "Unexpected JavaScript: " . $out);
     $out = CHtml::ajax(array('success' => 'function() { /* callback */ }'));
     $this->assertTrue(mb_strpos($out, "'success':function() { /* callback */ }", null, Yii::app()->charset) !== false, "Unexpected JavaScript: " . $out);
     $out = CHtml::ajax(array('success' => new CJavaScriptExpression('function() { /* callback */ }')));
     $this->assertTrue(mb_strpos($out, "'success':function() { /* callback */ }", null, Yii::app()->charset) !== false, "Unexpected JavaScript: " . $out);
 }
开发者ID:robregonm,项目名称:yii,代码行数:9,代码来源:CHtmlTest.php

示例6: prueba

				</tr>
				<tr><th style="text-align:center;">Grupo</th>
					<th style="text-align:center;">SubGrupo</th>
					<th style="text-align:center;">Seccion</th>
				</tr>
				</thead>
				<tbody id="data2">
					<?php 
$this->renderPartial('_ajaxContent2');
?>
				</tbody>
			</table>
			<script>
			function prueba() {
				<?php 
echo CHtml::ajax(array('type' => 'POST', 'url' => array("traspaso/actualizarAjax"), 'update' => '#data2', 'data' => array()));
?>
			}
			prueba();
			</script>
		</div>
		
	</fieldset>

	<div class="row buttons">
		<?php 
echo CHtml::link('Cancelar', array('delete', 'id' => $model->id), array('class' => 'button red')) . '&nbsp;&nbsp;&nbsp;';
echo CHtml::submitButton('Siguiente', array('class' => 'button blue'));
?>
	</div>
	
开发者ID:econesa,项目名称:sgbm_yii,代码行数:30,代码来源:_form.php

示例7: editdata1

</script>
<script type="text/javascript">
function editdata1()
{
    <?php 
echo CHtml::ajax(array('url' => array('invoicear/updateinvoicedet'), 'data' => array('id' => 'js:$.fn.yiiGridView.getSelection("detail1datagrid")'), 'type' => 'post', 'dataType' => 'json', 'success' => "function(data)\n            {\ndocument.getElementById('messages').innerHTML = '';\n                if (data.status == 'success')\n                {\n                    \$('#createdialog1 div.divcreate1').html(data.div);\n\t\t\t\t\t\$('#Invoicedet_invoicedetid').val(data.invoicedetid);\n\t\t\t\t\t\$('#Invoicedet_itemname').val(data.itemname);\n\t\t\t\t\t\$('#Invoicedet_qty').val(data.qty);\n\t\t\t\t\t\$('#Invoicedet_unitofmeasureid').val(data.unitofmeasureid);\n\t\t\t\t\t\$('#uomcode').val(data.uomcode);\n\t\t\t\t\t\$('#Invoicedet_price').val(data.price);\n\t\t\t\t\t\$('#Invoicedet_currencyid').val(data.currencyid);\n\t\t\t\t\t\$('#invdetcurrencyname').val(data.currencyname);\n\t\t\t\t\t\$('#Invoicedet_rate').val(data.rate);\n\t\t\t\t\t\$('#Invoicedet_description').val(data.description);\n                          // Here is the trick: on submit-> once again this function!\n                \$('#createdialog1').dialog('open');\n                }\n            else {\n                document.getElementById('messages').innerHTML = data.div;\n            }\n            } "));
?>
;
    return false;
}
</script>
<script type="text/javascript">
function deletedata1()
{
    <?php 
echo CHtml::ajax(array('url' => array('soheader/deleteinvoicedet'), 'data' => array('id' => 'js:$.fn.yiiGridView.getSelection("detail1datagrid")'), 'type' => 'post', 'dataType' => 'json', 'success' => "function(data)\n            {\n\n            } "));
?>
;
	$.fn.yiiGridView.update('detail1datagrid');
    return false;
}
</script>
<script type="text/javascript">
function refreshdata1()
{
    $.fn.yiiGridView.update('detail1datagrid');
    return false;
}
</script>
<?php 
$this->beginWidget('zii.widgets.jui.CJuiDialog', array('id' => 'createdialog1', 'options' => array('title' => 'Form Dialog', 'autoOpen' => false, 'modal' => true, 'width' => 'auto', 'height' => 'auto')));
开发者ID:bylinggha,项目名称:Capella-ERP-Indonesia,代码行数:31,代码来源:indexinvoicedet.php

示例8: array

<?php

if ($dataProvider != null) {
    if (isset($imageList) && $imageList == true) {
        echo "<div id='imageId' style='display:none'></div>";
        $this->beginWidget('zii.widgets.jui.CJuiDialog', array('id' => 'imageDeleteConfirmation', 'options' => array('title' => Yii::t('general', 'Delete Image'), 'autoOpen' => false, 'modal' => true, 'resizable' => false, 'buttons' => array("OK" => "js:function(){\n\t\t\t\t\t\t\t\t\t" . CHtml::ajax(array('url' => Yii::app()->createUrl('image/delete'), 'data' => array('id' => "js:\$('#imageId').html()"), 'success' => 'function(result) { 	
																 	try {
																 		$("#imageDeleteConfirmation").dialog("close");
																		var obj = jQuery.parseJSON(result);
																		if (obj.result && obj.result == "1") 
																		{
																			$.fn.yiiGridView.update("imageListView");
																		}
																		else 
																		{
																			$("#messageDialogText").html("Sorry,an error occured in operation");
																			$("#messageDialog").dialog("open");
																		}
	
																	}
																	catch(ex) {
																		$("#messageDialogText").html("Sorry,an error occured in operation");
																		$("#messageDialog").dialog("open");
																	}
																}')) . "}", "Cancel" => "js:function() {\n\t\t\t\t\t\t\$( this ).dialog( \"close\" );\n\t\t\t\t\t}"))));
        echo "Do you want to delete this image?";
        $this->endWidget('zii.widgets.jui.CJuiDialog');
    }
    $this->widget('zii.widgets.grid.CGridView', array('dataProvider' => $dataProvider, 'id' => 'imageListView', 'summaryText' => '', 'pager' => array('header' => '', 'firstPageLabel' => '', 'lastPageLabel' => ''), 'columns' => array(array('type' => 'raw', 'value' => 'CHtml::link("<img src=\\"".Yii::app()->createUrl("image/get", array(
														 "id"=>$data["id"],
														 "thumb"=>"ok"
开发者ID:Avinash1000,项目名称:traceper,代码行数:31,代码来源:getList.php

示例9: renderMessage

 /**
  * Render a message
  */
 protected function renderMessage($messageType, $message, $htmlOptions)
 {
     //render as javascript alert
     if ($messageType == 'js_alert') {
         $script = "alert('{$message}');";
         Yii::app()->clientScript->registerScript(__CLASS__ . '#' . $htmlOptions['id'], $script);
     } else {
         //render as ajax request
         if ($messageType == 'jq_ajax') {
             $this->_registerJQuery = true;
             echo CHtml::tag($this->tag, $htmlOptions, '');
             $script = CHtml::ajax(array('url' => $message, 'type' => 'get', 'update' => '#' . $htmlOptions['id']));
             Yii::app()->clientScript->registerScript(__CLASS__ . '#' . $htmlOptions['id'], $script);
         } else {
             echo CHtml::tag($this->tag, $htmlOptions, $message);
         }
     }
 }
开发者ID:ranvirp,项目名称:rdp,代码行数:21,代码来源:EUserFlash.php

示例10: editdata1

</script>
<script type="text/javascript">
function editdata1()
{
    <?php 
echo CHtml::ajax(array('url' => array('product/updatebasic'), 'data' => array('id' => 'js:$.fn.yiiGridView.getSelection("detailbasicdatagrid")'), 'type' => 'post', 'dataType' => 'json', 'success' => "function(data)\n            {\ndocument.getElementById('messages').innerHTML = '';\n                if (data.status == 'success')\n                {\n                    \$('#createdialog1 div.divcreate1').html(data.div);\n\t\t\t\t\t\$('#Productbasic_productbasicid').val(data.productbasicid);\n\t\t\t\t\t\$('#Productbasic_baseuom').val(data.baseuom);\n\t\t\t\t\t\$('#baseuomcode').val(data.baseuomcode);\n\t\t\t\t\t\$('#Productbasic_materialgroupid').val(data.materialgroupid);\n\t\t\t\t\t\$('#materialgroupcode').val(data.materialgroupcode);\n\t\t\t\t\t\$('#Productbasic_oldmatno').val(data.oldmatno);\n\t\t\t\t\t\$('#Productbasic_grossweight').val(data.grossweight);\n\t\t\t\t\t\$('#Productbasic_weightunit').val(data.weightunit);\n\t\t\t\t\t\$('#weightunitcode').val(data.weightunitcode);\n\t\t\t\t\t\$('#Productbasic_netweight').val(data.netweight);\n\t\t\t\t\t\$('#Productbasic_volume').val(data.volume);\n\t\t\t\t\t\$('#Productbasic_volumeunit').val(data.volumeunit);\n\t\t\t\t\t\$('#volumeunitcode').val(data.volumeunitcode);\n\t\t\t\t\t\$('#Productbasic_sizedimension').val(data.sizedimension);\n\t\t\t\t\t\$('#Productbasic_materialpackage').val(data.materialpackage);\n\t\t\t\t\t\$('#materialpackagename').val(data.materialpackagename);\n                          // Here is the trick: on submit-> once again this function!\n                \$('#createdialog1').dialog('open');\n                }\n            else {\n                document.getElementById('messages').innerHTML = data.div;\n            }\n            } "));
?>
;
    return false;
}
</script>
<script type="text/javascript">
function deletedata1()
{
    <?php 
echo CHtml::ajax(array('url' => array('product/deletebasic'), 'data' => array('id' => 'js:$.fn.yiiGridView.getSelection("detailbasicdatagrid")'), 'type' => 'post', 'dataType' => 'json', 'success' => "function(data)\n            {\n\n            } "));
?>
;
	$.fn.yiiGridView.update('detail1datagrid');
    return false;
}
</script>
<script type="text/javascript">
function refreshdata1()
{
    $.fn.yiiGridView.update('detailbasicdatagrid');
    return false;
}
</script>
<?php 
$this->beginWidget('zii.widgets.jui.CJuiDialog', array('id' => 'createdialog1', 'options' => array('title' => 'Form Dialog', 'autoOpen' => false, 'modal' => true, 'width' => 'auto', 'height' => 'auto')));
开发者ID:bylinggha,项目名称:Capella-ERP-Indonesia,代码行数:31,代码来源:indexbasic.php

示例11: reSetBlocksByParent

    }
    
    function reSetBlocksByParent(data){
         $.each(data, function(key_parent, val_parent){                       
                if(key_parent=='blocks'){                    
                        $.each(val_parent, function(k,v) {                                 
                             setBlocksForRegion(v.region,v.title,v.id,v.status);              
                        });
                }
        });
    }
    
    
    function getRegionsByLayouts(){
        <?php 
echo CHtml::ajax(array('url' => array('changeLayout'), 'data' => array('layout' => 'js:$(\'#layout_select\').val()', 'YII_CSRF_TOKEN' => Yii::app()->getRequest()->getCsrfToken()), 'type' => 'post', 'dataType' => 'json', 'success' => "function(data)\n            {    \n                block_count=0;\n                createRegionsFromJson(data);\n                initBlocks();\n            } "));
?>
    }
    
    function setBlocksForRegion(region,title,id,status){
        var span_html='<input type="checkbox" class="checkbox_region" id="checkbox_'+block_count+'_'+region+'_'+id+'"/><span class="span_block">'+title+'</span> - <span><select name="Page[regions]['+region+'][status][]" id="select_region_'+block_count+'_'+region+'_'+id+'"><option value="<?php 
echo ConstantDefine::PAGE_BLOCK_ACTIVE;
?>
"><?php 
echo PageBlock::convertPageBlockStatus(ConstantDefine::PAGE_BLOCK_ACTIVE);
?>
</option><option value="<?php 
echo ConstantDefine::PAGE_BLOCK_DISABLE;
?>
"><?php 
echo PageBlock::convertPageBlockStatus(ConstantDefine::PAGE_BLOCK_DISABLE);
开发者ID:ntquyen,项目名称:GXC-CMS,代码行数:31,代码来源:page_form_widget.php

示例12: registerClientScript

 /**
  * Registers the needed client scripts.
  * @since 1.0.2
  */
 public function registerClientScript()
 {
     $cs = Yii::app()->clientScript;
     $id = $this->imageOptions['id'];
     $url = $this->getController()->createUrl($this->captchaAction, array(CCaptchaAction::REFRESH_GET_VAR => true));
     if ($this->showRefreshButton) {
         $cs->registerScript('Yii.CCaptcha#' . $id, 'dummy');
         $label = $this->buttonLabel === null ? Yii::t('yii', 'Get a new code') : $this->buttonLabel;
         $button = $this->buttonType === 'button' ? 'ajaxButton' : 'ajaxLink';
         $html = CHtml::$button($label, $url, array('success' => 'js:function(html){jQuery("#' . $id . '").attr("src",html)}'), $this->buttonOptions);
         $js = "jQuery('#{$id}').after(\"" . CJavaScript::quote($html) . '");';
         $cs->registerScript('Yii.CCaptcha#' . $id, $js);
     }
     if ($this->clickableImage) {
         $js = "jQuery('#{$id}').click(function(){" . CHtml::ajax(array('url' => $url, 'success' => "js:function(html){jQuery('#{$id}').attr('src',html)}")) . '});';
         $cs->registerScript('Yii.CCaptcha#2' . $id, $js);
     }
 }
开发者ID:Jride,项目名称:accounting-thaiconnections,代码行数:22,代码来源:CCaptcha.php

示例13: array

			</div>

		</div>
	</div>

	<div class="row buttons">
		<?php 
echo $form->hiddenField($new_event, 'user_id', array('value' => Yii::app()->user->id));
?>
		<?php 
echo CHtml::submitButton('Update');
?>
	</div>

	<?php 
$this->endWidget();
?>

</div><!-- form -->

<?php 
$ajax = CHtml::ajax(array('url' => array('selectRemarks'), 'dataType' => 'html', 'type' => 'post', 'data' => 'js: {status_id:$(this).val()} ', 'success' => 'function(data){
		$("#rm").children().remove();
		$("#rm").append(data);
		return true;
	}'));
$cs = Yii::app()->clientScript;
$script = <<<SCRIPT
    \$('#ShipmentEvent_status').live('change',function(){ {$ajax} });
SCRIPT;
$cs->registerScript('change_status', $script);
开发者ID:aantonw,项目名称:dcourier.system,代码行数:31,代码来源:updateBulk.php

示例14: array

    /*
     * if status is zero, it means friend ship request is made and not yet confirmed.
     * requester who made first friend request. if one is requester he cannot approve friendship
     */
    ?>
<div style='float: left;'>
<?php 
    echo CHtml::link('<img src="images/approve.png"  />', '#', array('onclick' => CHtml::ajax(array('url' => $this->createUrl('users/approveFriendShip', array('friendShipId' => $data['friendShipId'])), 'success' => 'function(result) { alert(result); }'))));
    ?>
	
</div>	
<?php 
} else {
    if (isset($data['status']) && $data['status'] == -1) {
        /*
         * if status is not exist or equal to -1 it means there is no relation between these users.
         */
        ?>
<div style='float: left;'>
<?php 
        echo CHtml::link('<img src="images/user_add_friend.png"  />', '#', array('onclick' => CHtml::ajax(array('url' => $this->createUrl('users/addAsFriend', array('friendId' => $data['id'])), 'success' => 'function(result) { alert(result); }'))));
        ?>
					 
</div>	
<?php 
    }
}
?>
</div>

</br>
开发者ID:Avinash1000,项目名称:traceper,代码行数:31,代码来源:_user.php

示例15: array

$this->beginWidget('bootstrap.widgets.TbModal', array('id' => 'ModalDialog'));
?>
<div class="modal-header">
    <a class="close" data-dismiss="modal">x</a>
    <h3><?php 
echo $this->modalTitle;
?>
</h3>
</div>

<div class="modal-body">
</div>


<?php 
$this->endWidget();
?>

<script type="text/javascript">
// here is the magic
function dialogJavaScript()
{
    <?php 
echo CHtml::ajax(array('url' => $this->ajaxCreateURL, 'data' => "js:\$(this).serialize()", 'type' => 'post', 'dataType' => 'json', 'success' => "function(data)\r\n            {\r\n                if (data.status == 0)\r\n                {\r\n                    \$('#ModalDialog div.modal-body').html(data.div);\r\n                    // Here is the trick: on submit-> once again this function!\r\n                    \$('#ModalDialog div.modal-body form').submit(dialogJavaScript);\r\n                }\r\n                else\r\n                {\r\n                    setTimeout(\"\$('#ModalDialog').modal('hide') \", 500);\r\n                    // Refresh the grid with the update\r\n                    //\$.fn.yiiGridView.update('grid-view');\r\n                    \$('#grid-view').yiiGridView('update');\r\n                }\r\n \r\n            }"));
?>
;
    return false; 
 
}

</script>
开发者ID:mehulsbhatt,项目名称:sale_purchase_tracking,代码行数:31,代码来源:tableList.php


注:本文中的CHtml::ajax方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。