Yii2模态与复合键
Yii2 modal with composite key
有人能帮我拿复合键吗?我不能正常工作。
function init_click_handlers(){
$(".button-endereco").click(function(e) {
var fcodigo = $(this).closest("tr").data("codigo");
var fcodigopessoa = $(this).closest("tr").data("codigopessoa");
var map = {codigo: $(this).closest("tr").data("codigo"), codigopessoa: $(this).closest("tr").data("codigopessoa")};
$.get(
"update ",
{
codigo: fcodigo
codigopessoa: fcodigopessoa
},
function (data)
{
$("#endereco-modal").find(".modal-body").html(data);
$(".modal-body").html(data);
$("#endereco-modal").modal("show");
}
);
});
}
init_click_handlers(); //first run
$("#endereco_id").on("pjax:success", function() {
init_click_handlers(); //reactivate links in grid after pjax update
});
$url = Yii::$app->urlManager->createUrl('../endereco/update?codigo='.$dataProvider->codigo.'&codigopessoa='.$dataProvider->codigopessoa);
如果您想引用$dataProvider中的数据,您首先需要获得所需的模型。在dataProvider中,所有与您的查询相关的模型都是可用的,您可以从模型数组中获得通过适当索引访问的特定模型,例如:
myModel = $dataProvider->models[yourIndex]
myValue = myModel->myField
在你的例子中,你可以通过这种方式获得
myModel = $dataProvider->models[0]:
myValue = myModel->codigo;
我得到了90%的响应,但无法捕获我的复合密钥(密码,codigopessoa),强制值测试函数,它成功了。所以缺少我得到的列值(复合键)。
function init_click_handlers(){
$(".button-endereco").click(function(e) {
fcodigo = $(this).closest("tr").data("codigo");
fcodigopessoa = $(this).closest("tr").data("codigopessoa");
$.ajax({
url: "'.Yii::$app->urlManager->createUrl('endereco/update').'",
type: "GET",
data: {"codigo": parseInt(17), "codigopessoa":parseInt(8)},
dataType: "html",
success: function(data) {
$("#endereco-modal").find(".modal-body").html(data);
$(".modal-body").html(data);
$("#endereco-modal").modal("show");
}
});
});
}
init_click_handlers(); //first run
$("#endereco_id").on("pjax:success", function() {
init_click_handlers(); //reactivate links in grid after pjax update
});
〔100%工作〕最终得到了它,对于那些想要使用带有复合键的Gridview(kartik)的人来说,代码如下:
function init_click_handlers(){
$(".button-endereco").click(function(e) {
chave = $(this).closest("tr").data("key");
$.ajax({
url: "'.Yii::$app->urlManager->createUrl('endereco/update').'",
type: "GET",
data: {"codigo": parseInt(chave["codigo"]), "codigopessoa":parseInt(chave["codigopessoa"])},
//data: {keylist: parseInt(keys)},
dataType: "html",
success: function(data) {
$("#endereco-modal").find(".modal-body").html(data);
$(".modal-body").html(data);
$("#endereco-modal").modal("show");
}
});
});
}
init_click_handlers(); //first run
$("#endereco_id").on("pjax:success", function() {
init_click_handlers(); //reactivate links in grid after pjax update
});
相关文章:
- 我想使用模态通过php文件发送邮件,并且我希望在提交关闭后关闭pop
- 打开一个模态并将其链接到AngularJS中的指令
- SemanticUI模态not onDeny/onApprove事件未激发
- 有没有比在app.js上绑定模块名称更好的方法来动态加载视图模型和视图以显示模态
- 如何通过所选索引(AngularJS)在模态弹出窗口中显示数据
- 包含数据库中相关信息的开放模态
- bootstrap消除模态并显示另一个模态
- 模态提示-如何重写此代码
- 模态框无法正常工作
- 将数据传递给由服务创建的Ionic模态
- iframe模态无法关闭
- 点击AngularJS模态窗口捕捉背景事件
- jqueryajax调用是复制url,当在模态视图之后在外部js文件中进行调用时
- 使用模态对话框(JQuery)编辑函数
- 如何在模态实例中使用filter
- 页面上有多个模态框
- 如果满足某些条件,如何在不调用模态的情况下首先调用类
- 在将缩略图链接到模态时遇到问题
- jQuery模态弹出的行为类似于确认和警报对话框
- Yii2模态与复合键