【问题标题】:Codeigniter when i click delete i want pop up notification if if click yes or notCodeigniter 当我单击删除时,如果单击是或否,我想弹出通知
【发布时间】:2013-05-29 07:40:30
【问题描述】:

型号:

 function delete_exchange($ExchangeRateId) {
    $this -> db -> where('ExchangeRateId', $ExchangeRateId);
    $this -> db -> delete('exchange_rate');
}

控制器:

function delete($ExchangeRateId) {
        $user_type = $this -> session -> userdata('user_type');
        if ($user_type != "admin") {
            redirect(base_url() . 'user_admin/login');
        }
        $this -> all -> delete_exchange($ExchangeRateId);
        redirect(base_url() . 'exchange/index');
    }

删除按钮是明确的,这里我想要一个像弹出是的通知,否则必须运行我的意思是删除的操作

【问题讨论】:

  • 尝试在view中调用popup,然后根据action做ajax调用。
  • 你可以使用jquery对话框,jqueryui.com/dialog,它提供了ok/cancel功能

标签: php javascript codeigniter


【解决方案1】:

查看页面

<script>
function doconfirm()
{
    job=confirm("Are you sure to delete permanently?");
    if(job!=true)
    {
        return false;
    }
}
</script>

删除链接

<a href="<?php echo site_url();?>/mycontroller/delete/<?php print($data->auc_id);?>">
   <img  src='images/delete.gif' title="Delete" onClick="return doconfirm();" >
</a>

【讨论】:

  • @WelcomeAlways 很棒!但我不明白你的问题。当请求的删除 id 未在表中找到或请求的删除 id 在表中为多个时,您想在哪种情况下重定向回?
【解决方案2】:

在你看来这样做..

<a href="<?PHP site_url('delete/').$ExchangeRateId;?>" onclick="return deletechecked();">delete<?a>

    function deletechecked()
    {
        if(confirm("Delete selected messages ?"))
        {
            return true;
        }
        else
        {
            return false;  
        } 
   }

【讨论】:

  • 2013 年 6 月 3 日 7:29 提问 | 2013 年 6 月 3 日 7:33 回答。不迟到的兄弟..:)
【解决方案3】:

你需要做那个客户端..在你的视图中......你想要构造的按钮的 onclick 事件使用confirm()...

将此添加到您的按钮..

<button onclick="confirmation()" />

function confirmation()
{
   var r=confirm("are you sure to delete?")
   if (r==true)
  {
    alert("pressed OK!")
    // call the controller
  }
  else
  {
   alert("pressed Cancel!");
   return false;
  }
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-10-26
    • 1970-01-01
    相关资源
    最近更新 更多