簡體   English   中英

編輯項目模態彈出 asp.net mvc

[英]Edit item modal popup asp.net mvc

我嘗試使用此示例: MVC 5 Edit Bootstrap Modal Popup我有Index頁面,我在該頁面上發送onclickEdit(id)我有Edit頁面,我的模態 html 放置在該頁面上。

.js:

{     
var id = $(elem).data('assigned-id');     
alert("1");     
$.ajax({         
url: '/Course/Edit/id=' + id,         
success: function (data) {             
alert("2");             
$('#modalWrapper').html(data);             
$('#editModal').modal();         
}     
}); 
}

alert("1") 有效, alert("2") 無效。

controller:

public IActionResult Edit(Guid id)         
{             
return PartialView(_courses.Find(id));         
}

我檢查了,我進入Edit() ,它通過了,但我沒有進入 ajax 成功 我應該改變什么? 非常感謝

看起來您在modal() function 中缺少字符串輸入'show' 通過添加它,它將使模態可見。

$('#editModal').modal('show');

引導文檔: https://getbootstrap.com/docs/4.1/components/modal/#modalshow

更新

$.ajax({
        url: '/Course/Edit/id=' + id,
        type: 'GET',
        cache: false,
        success: function (result) {
            alert("2");
            $('#modalWrapper').html(result);             
            $('#editModal').modal('show');  
        }
    });

更新

您是否在 Chrome 瀏覽器的開發控制台中收到任何錯誤? 按 F12 訪問它。

在此處輸入圖像描述

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM