使用编码器点火器保存数据后显示通知
show notify after save data using codeigniter
我试图在保存数据时显示通知并将其显示在视图中,但不运行我使用通知.js . 如果有人可以帮助我?
这是我的控件保存
function save() {
$data = array(
'idsupplier' => $this->input->post('idsupplier'),
'namasupplier' => $this->input->post('namasupplier'),
'alamat' => $this->input->post('alamat'),
'telp' => $this->input->post('telp'),
'fax' => $this->input->post('fax'),
'email' => $this->input->post('email'),
'web' => $this->input->post('web'),
'kontak1' => $this->input->post('kontak1'),
'hp1' => $this->input->post('hp1'),
'email1' => $this->input->post('email1'),
'kontak2' => $this->input->post('kontak2'),
'hp2' => $this->input->post('hp2'),
'email2' => $this->input->post('email2'));
$this->mcrud->addsupplier($data);
echo '<script>Notify("Alat Baru Berhasil Ditambahkan Ke Database ", null, null, type);</script>';
redirect('instrument/detailsupplier');
这是我的观点
<style>
#notifications {
cursor: pointer;
position: fixed;
right: 0px;
z-index: 9999;
bottom: 0px;
margin-bottom: 22px;
margin-right: 15px;
max-width: 300px;
}
</style>
<div id="notifications"></div>
<script>
$( document ).ready(function() {
Notify("Alat Baru Berhasil Ditambahkan Ke Database ", null, null, type);
});
</script>
使用会话闪存数据同样容易
function save() {
$data = array(
'idsupplier' => $this->input->post('idsupplier'),
'namasupplier' => $this->input->post('namasupplier'),
'alamat' => $this->input->post('alamat'),
'telp' => $this->input->post('telp'),
'fax' => $this->input->post('fax'),
'email' => $this->input->post('email'),
'web' => $this->input->post('web'),
'kontak1' => $this->input->post('kontak1'),
'hp1' => $this->input->post('hp1'),
'email1' => $this->input->post('email1'),
'kontak2' => $this->input->post('kontak2'),
'hp2' => $this->input->post('hp2'),
'email2' => $this->input->post('email2'));
);
}
$this->mcrud->addsupplier($data);
$this->session->set_flashdata('something', 'Alat Baru Berhasil Ditambahkan Ke Database');
// Codeigniter set flash data will only work when your redirecting
redirect('instrument/detailsupplier');
}
然后在您的视野中
<?php if ($this->session->flashdata('something')) {?>
<div id="notifications"><?php echo $this->session->flashdata('something');</div>
<?php }?>
成功时设置闪烁消息并检查闪烁消息并触发通知。请参阅下面的代码。
function save() {
$data = array(
'idsupplier' => $this->input->post('idsupplier'),
'namasupplier' => $this->input->post('namasupplier'),
'alamat' => $this->input->post('alamat'),
'telp' => $this->input->post('telp'),
'fax' => $this->input->post('fax'),
'email' => $this->input->post('email'),
'web' => $this->input->post('web'),
'kontak1' => $this->input->post('kontak1'),
'hp1' => $this->input->post('hp1'),
'email1' => $this->input->post('email1'),
'kontak2' => $this->input->post('kontak2'),
'hp2' => $this->input->post('hp2'),
'email2' => $this->input->post('email2'));
$this->mcrud->addsupplier($data);
//set flash message
$this->session->set_flashdata('msg','Alat Baru Berhasil Ditambahkan Ke Database');
redirect('instrument/detailsupplier');
在您的视野中
<?php if ($this->session->flashdata('msg')) {?>
<script>
Notify(<?=$this->session->flashdata('msg')?>, null, null, type);
</script>
<?php } ?>
相关文章:
- notify.js没有'如果另一个窗口被聚焦,则不显示通知
- 在ajax调用后在rails中显示通知
- Cordova:如何显示系统通知
- Toast通知未显示在右下角
- 通知权限被拒绝(桌面推送通知).通知弹出窗口不会't以镀铬显示
- Chrome扩展通知未显示contextMessage
- 重定向后在页面上显示通知
- 无法发送应用请求,显然已发送,但未显示通知用户
- 使用AngularFire创建用户并调用工厂以显示通知
- 单击“保存到CSV”按钮后显示通知(如果未安装Flash Player)
- 使用编码器点火器保存数据后显示通知
- 如何在用户移动到另一个页面时向用户显示通知而不保存数据
- 我如何显示通知每用户与jquery和php
- 我必须重新加载chrome扩展以显示通知
- 用于在浏览器标头中显示通知的选项
- 如何使用代码点火器在控制器的锚点内显示通知
- 如何根据在 HTML5 中使用服务器发送的事件检索的数据显示通知
- 显示通知直到超时除非悬停(jQuery)
- 如果表单包含单词,则显示通知
- 显示通知Chrome扩展