首页 \ 问答 \ 如何暂停和重启jquery datatables插件(how to pause and restart jquery datatables plugin)

如何暂停和重启jquery datatables插件(how to pause and restart jquery datatables plugin)

我正试图通过单击按钮来转换表格中的一行。 我的问题是该表使用Datatables插件,我想禁用脚本(过滤,排序ecc。),并在提交后重新激活它。

我现在正在尝试使用bDestroy,同时启用了禁用过滤和排序的新功能,但我想完全禁用该脚本,因为它可能会给我的脚本带​​来新的问题。


I'm trying to transform a row of my table in a form by clicking a button. My problem is the table uses Datatables plugin, and I would like to disable the script (filtering, sorting ecc.), and reactivate it after submit.

I was trying now to use bDestroy while starting a new istance with filtering and sorting disabled, but I would like to totally disable the script, because it may create new issues to my script.


原文:https://stackoverflow.com/questions/20451305
更新时间:2024-01-16 10:01

最满意答案

如果您正在使用cakePHP 2.x,那么您可以在模型的回调函数中设置密码加密,然后在之前保存()

<?php
// app/Model/User.php
App::uses('AuthComponent', 'Controller/Component');
class User extends AppModel {

// ...

public function beforeSave($options = array()) {
    if (isset($this->data[$this->alias]['password'])) {
        $this->data[$this->alias]['password'] = AuthComponent::password($this->data[$this->alias]['password']);
    }
    return true;
}

?>

有关更多信息,请点击链接 。 如果您仍想在控制器中加密密码,那么您可以使用类似的代码。

public function add() {
    $this->set("title_for_layout", "Register");

    if($this->request->is("post")) {
        $this->User->set($this->request->data);

    if($this->User->save(array("password" => $this->Auth->password($this->request->data["User"]["password"])))) {
            $this->Session->setFlash(__("Successfully registred."), "flash_success");
            $this->redirect("/login");
    } else {
        $this->Session->setFlash(__("Validation failed."), "flash_danger");
    }
    }
}

?>

如果您正在使用cakePHP 2.4或更高版本,请按照此处的文档进行操作。


If you're using cakePHP 2.x then you can set password encryption in the model's callback function beforeSave() as

<?php
// app/Model/User.php
App::uses('AuthComponent', 'Controller/Component');
class User extends AppModel {

// ...

public function beforeSave($options = array()) {
    if (isset($this->data[$this->alias]['password'])) {
        $this->data[$this->alias]['password'] = AuthComponent::password($this->data[$this->alias]['password']);
    }
    return true;
}

?>

For more information follow the link. IF you still want to encrypt password in the controller then you can use the code like.

public function add() {
    $this->set("title_for_layout", "Register");

    if($this->request->is("post")) {
        $this->User->set($this->request->data);

    if($this->User->save(array("password" => $this->Auth->password($this->request->data["User"]["password"])))) {
            $this->Session->setFlash(__("Successfully registred."), "flash_success");
            $this->redirect("/login");
    } else {
        $this->Session->setFlash(__("Validation failed."), "flash_danger");
    }
    }
}

?>

If you're using the cakePHP 2.4 or later then follow the documentation here.

相关问答

更多
  • 虽然这是一个非常糟糕的想法,并打开你的系统进行各种黑客攻击。 您应该在数据库中创建管理员用户。 但是,您实际问题的答案是: identify()不接受任何参数,而是基于当前请求数据进行身份验证,因此如果您没有在数据库中匹配该数据的用户,它将总是返回false。 你想要做的只是调用setUser($getMasterLogin) ,如下所示: if(($data['email'] == 'admin@gmail.com') && ($data['password'] == '123456')) { ...
  • 您已将Form身份验证器配置为使用email字段来标识用户,但您的表单不使用该字段,它使用username段,因此身份验证者将找不到发布的数据。 也可以看看 Cookbook>控制器>组件>验证>配置验证处理程序 Cookbook>教程与示例> CMS教程 - 身份验证>添加登录 You have configured the Form authenticator to use the email field for identifying the user, but your form doesn't u ...
  • 在Cake 2.x中,它有点不同 $this->Auth->authenticate = array( 'Form' => array( 'fields' => array('username' => 'email', 'password' => 'password'), ), ); In Cake 2.x it's a little different $this->Auth->authenticate = array( 'Form' => array( ...
  • 你提出的是你想做什么的适当方式 public function beforeFilter() { $this->Auth->allow(); } 阅读API文档 获取当前控制器中不需要身份验证的操作列表,或者不允许所有操作的参数。 所以没有参数的函数应该允许普通用户(未登录)访问该控制器的每个动作。 编辑: 对不起,您的代码中遗漏了版本参考。 它在这里说 $this->Auth->allow('*'); 是Cake 2.0的合适方式(以及以前的版本,正如@mark所指出的那样) What yo ...
  • 如果您正在使用cakePHP 2.x,那么您可以在模型的回调函数中设置密码加密,然后在之前保存() data[$this->alias ...
  • CakePHP可能不明白它需要在比较之前对密码字段进行哈希处理,因为你已经重命名了你的字段......这可以通过你可以在字段中输入哈希密码并成功登录来证实...... 'Auth.fields' => array('username' => 'usuario', 'password' => 'passwd'), 尝试将您的数据库列重命名为密码,并确保您在视图中使用FormHelpers来排除这是您的问题。我为糟糕的答案道歉,但这是我可以根据您发布的内容做出的最好的。 如果你回复我的回答,我很乐意改进它。 ...
  • 我最终解决这个问题的方法是完全按照CakePHP的说法完成教程。 我也升级到2.1.2。 我在运行2.1.0。 http://book.cakephp.org/2.0/en/tutorials-and-examples/blog-auth-example/auth.html 然后我慢慢添加了我需要的配置。 有关我引用的Auth组件的信息: http://book.cakephp.org/2.0/en/core-libraries/components/authentication.html 真的是我的问题是 ...
  • 起初我也很困惑地看着蛋糕文档。 但后来我发现了。 您的代码顺序错误。 首先,你必须这样做 $this->Html->addCrumb('Users','/users'); $this->Html->addCrumb('Add User',['controller'=>'Users','action'=>'add 然后是getCrumbs, echo $this->Html->getCrumbs('>', [ 'text'=>$this->Html->image('home.png',['alt'=>'Ho ...
  • 我解决了这些问题: 确保服务器上的时间是正确的。 否则会话将无法工作。 修正acos表中的表格数据。 特别要确保'lft'和'rght'值是正确的。 此页面可能有所帮助: http : //www.sitepoint.com/hierarchical-data-database-2/ 您需要将您想要使用的每个动作添加到acos表。 如果你不这样做,你不能做这个动作。 即使你允许孔控制器。 I solved the problems by: Make sure the time on the server i ...
  • 我解决了问题...我使用参数为空的函数。 有效 array( 'authorize' => array( 'Actions' => ar ...

相关文章

更多

最新问答

更多
  • 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
  • 如何通过引用返回对象?(How is returning an object by reference possible?)
  • 矩阵如何存储在内存中?(How are matrices stored in memory?)
  • 每个请求的Java新会话?(Java New Session For Each Request?)
  • css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
  • 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
  • xcode语法颜色编码解释?(xcode syntax color coding explained?)
  • 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
  • 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
  • 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
  • 西安哪有PLC可控制编程的培训
  • 在Entity Framework中选择基类(Select base class in Entity Framework)
  • 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
  • 电脑二级VF有什么用
  • Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
  • 金华英语角.
  • 手机软件如何制作
  • 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
  • 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
  • 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
  • Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
  • 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
  • python的访问器方法有哪些
  • DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
  • 在Ruby中对组合进行排序(Sorting a combination in Ruby)
  • 网站开发的流程?
  • 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
  • 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
  • 透明度错误IE11(Transparency bug IE11)
  • linux的基本操作命令。。。