• 欢迎访问搞代码网站,推荐使用最新版火狐浏览器和Chrome浏览器访问本网站!
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏搞代码吧

yii_wiki_204_using-cjuidialog-to-edi_php

php 搞代码 7年前 (2018-06-21) 199次浏览 已收录 0个评论
 /***  Using CJuiDialog to edit rows in a CGridView      http://www.yiiframework.com/wiki/204/using-cjuidialog-to-edit-rows-in-a-cgridview    translated by php攻城师    http://blog.csdn.net/phpgcs    Scenario  Solution  Column hyperlink  Javascript function    **/      /***  背景      Scenario  ***/       我这里有一个 一系列的 clients/events 所属的 CGridView , 对每一行 (eventClient), 我想要实现快速的编辑 eventClient对话框。      我的方法基于 这篇wiki http://www.yiiframework.com/wiki/145/cjuidialog-for-create-new-model/      /***    解决方法  Solution     ***/      首先基于 wiki 145 做了所有工作后, 再来 修改我们 的CGridView:      Column hyperlink       对每一列 , 在js 函数中设置 _updateComment_url 属性 为需要的 url。      array(       'name'=>'comment',       'header'=>'Comments',       'type'=>'raw',       'value'=>'CHtml::link(           ($data["comment"]?$data["comment"]:"(comment)"),           "",           array(               /'style/'=>/'cursor: pointer; text-decoration: underline;/',               /'onclick/'=>/'{                   updateComment._updateComment_url="/'.                       Yii::app()->createUrl(                           "eventClient/updateComment",                           array("id"=>$data["id"])                       )                   ./'";                   updateComment();                   $("#dialogComment").dialog("open");}/'               )           );',   ),         Javascript function       在同一个页面我们将 调用这个 动作的 updateComment() 方法包含进来。       <script type="text/javascript">       function updateComment()   {       // public property       var _updateComment_url;           <?php echo CHtml::ajax(array(           'url'=>'js:updateComment._updateComment_url',           'data'=> "js:$(this).serialize()",           'type'=>'post',           'dataType'=>'json',           'success'=>"function(data)               {                   if (data.status == 'failure')                   {                       $('#dialogComment div.divComment').html(data.div);                       // Here is the trick: on submit-> once again this function!                       $('#dialogComment div.divComment form').submit(updateComment);                   }                   else                   {                       $('#dialogComment div.divComment').html(data.div);                       setTimeout(/"$('#dialogComment').dialog('close') /",2000);                           // Refresh the grid with the update                       $.fn.yiiGridView.update('event-client-grid');                   }               } ",       ))?>;       return false;       }       </script>  

欢迎大家阅读《yii_wiki_204_using-cjuidialog-to-edi_php,跪求各位点评,若觉得好的话请收藏本文,by 搞代码


搞代码网(gaodaima.com)提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请说明详细缘由并提供版权或权益证明然后发送到邮箱[email protected],我们会在看到邮件的第一时间内为您处理,或直接联系QQ:872152909。本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:yii_wiki_204_using-cjuidialog-to-edi_php
喜欢 (0)
[搞代码]
分享 (0)
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址