【问题标题】:CakePHP: bootstrap x-editable data not savedCakePHP:bootstrap x-editable 数据未保存
【发布时间】:2016-12-29 18:47:45
【问题描述】:

我想使用 bootstrap x-editable 内联编辑列表页面上的变量。我以前使用过这个功能,但是在一张只有一个 ID 和一个值的表上效果很好。现在在这种情况下,用户单击内容概览页面中的用户名。单击后,用户名会变成带有用户名的选择框。这很好用。但是在保存时,数据不会被存储。至少它存储为 0

在视图中:

<a href="#" data-name="newValue" class="xedit-username editable editable-click" 
data-url="/contents/editassignee/<?php echo $content['Content']['id'];?>"><?php echo $content['User']['username'];?></a>

点击后会变成(看起来没问题):

<a href="#" data-pk="5" data-name="newValue" class="xedit-username editable editable-click editable-open" 
data-url="/contents/editassignee/5" style="display: none;">alvin</a>
<span class="editable-container editable-inline">
<div>
    <div class="editableform-loading" style="display: none;"></div>
    <form class="form-inline editableform" style="">
        <div class="form-group"><div>
        <div class="editable-input">
            <select class="form-control input-medium">
                <option value="1">alvin</option>
                <option value="83">robert</option>
            </select>
        </div>
    </form>
</div>
</span>

激活选择框的脚本是:

$('.xedit-username').editable({
    type: 'select',
    title: 'Select username',
    source: '/users/listing',
    showbuttons: false
});

并且保存后,使用内容控制器中的这个函数:

public function editassignee($id = null) {
    $this->autoRender = false;
    $this->Content->id = $id;
    $this->Content->saveField('user_id', $_POST['newValue']);
}

真的希望有人看到我在这里出错的地方,或者也许有人可以告诉我什么是最简单的调试方法。提前感谢

【问题讨论】:

  • 使用您的浏览器开发工具(右键单击、检查元素、网络选项卡),对其进行测试并查看实际发布的数据
  • 知道了。这似乎是 x-editable 文档中的一个缺陷。 data-name="newValue" 不是发送数据的名称。但它是这样的:name=newValue&value=1&pk=7 => Thanx Ananth

标签: jquery twitter-bootstrap cakephp x-editable


【解决方案1】:

我对 x-editable 不是很熟悉,但 select 不应该有 name 值;

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-11-24
    • 1970-01-01
    • 1970-01-01
    • 2014-04-21
    相关资源
    最近更新 更多