Bootstrap popup doesn't open with the first click, and not loaded by ID the data you need, what's wrong?

In General, the desired grid in the pop-up, the ID is transmitted to a server, and there III makes renderpartial, code jQuery:
$('#warningHistory').click(function(e) {
$.post(
$(this).data('uri'),
{
 'id': $(this).data('id')
},
 function(result) {
$('.report-index').append(result);
 $('#warningHistoryModal').on('shown.bs.modal', function () {
$('#closeButton').focus()
})
}
);
 });


fixed, but somehow not what, it's worse
$('#warningHistory').click(function(e) {
e.preventDefault();
 $('#warningHistoryModal').on('shown.bs.modal', function () {
$.post(
$(this).data('uri'),
{
 'id': $(this).data('id')
},
 function (result) {
$('.report-index').append(result);
}
)
}
);
 });
July 9th 19 at 10:38
1 answer
July 9th 19 at 10:40
1. the code You gave does not open a modal and sends an ajax request
2. why renderPartial, not renderAjax?
3. Bind ajax to not click, and the event "show.bs.modal" or "shown.bs.modal" (second more reliable), then everything will be OK.
: What does not and what did You do? - Henderson_Beat commented on July 9th 19 at 10:52
as it went - sunny.Reichel78 commented on July 9th 19 at 10:43
: What specifically? - Henderson_Beat commented on July 9th 19 at 10:46
did not respond server - sunny.Reichel78 commented on July 9th 19 at 10:49
I looked in the console, even the request is not sent, set the code as You wrote - sunny.Reichel78 commented on July 9th 19 at 10:55
: The code I gave, I gave the algorithm, the question is what have You written - Henderson_Beat commented on July 9th 19 at 10:58

Find more questions by tags BootstrapJavaScriptjQueryPHPYii