简体   繁体   中英

Edit item modal popup asp.net mvc

I try to use this example: MVC 5 Edit Bootstrap Modal Popup I have Index page, on which I send onclickEdit(id) I have Edit page, where my modal html is placed.

.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") works, alert("2") not.

controller:

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

I checked, I come into Edit() , it passed, but I don't come into ajax success What shoud I change? Many thanks

Looks like you are missing string input 'show' in the modal() function. By adding it, it will make the modal visible.

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

Bootstrap documentation: https://getbootstrap.com/docs/4.1/components/modal/#modalshow

Update

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

Update

Do you get any errors in the development console in the Chrome browser? Push F12 to access it.

在此处输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM