gpt4 book ai didi

javascript - xeditable onbeforesave 不触发

转载 作者:行者123 更新时间:2023-11-30 00:10:07 27 4
gpt4 key购买 nike

我对 xeditable 指令有疑问。 onbeforesave 没有触发,即使就地编辑在客户端运行良好。我无法从 onbeforesave 或 onaftersave 得到任何反应。

我在我的项目中包含了 Angular 版本 1.5.0。我正在这样设置元素,它在表格中:

<tr ng-repeat="job in jobs">
<td>{{ job._id }}<i ng-click="removeJob(job._id)" class="fa fa-trash-o" aria-hidden="true"></i></td>
<td>{{ job.title }}</td>
<td editable-text="job.description" onbeforesave="alert('hello');">{{ job.description || "empty" }}</td>
</tr>

但是我无法在单击保存时关闭警报。

最佳答案

如果你看the documentation :

One way to submit data on server is to define onbeforesave attribute pointing to some method of scope

onbeforesave 接受一个范围方法,所以 alert('hello') 在这种情况下试图调用一些 $scope.alert 不存在的方法。为了使这项工作尝试类似的东西

// in your controller

$scope.test = function(data) {
alert(data);
};

// in your template

<tr ng-repeat="job in jobs">
<td>{{ job._id }}<i ng-click="removeJob(job._id)" class="fa fa-trash-o" aria-hidden="true"></i></td>
<td>{{ job.title }}</td>
<td editable-text="job.description" onbeforesave="test($data)">{{ job.description || "empty" }}</td>
</tr>

关于javascript - xeditable onbeforesave 不触发,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36851730/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com