S
S
sl1m_dogg2016-05-30 13:25:45
JavaScript
sl1m_dogg, 2016-05-30 13:25:45

The bootstrap popup does not open from the first click, and the necessary data is not loaded by ID, what's wrong?

In general, you need a grid in the popup, when you click, the ID is transferred to the server, and there it makes a renderPartial, jquery code:

$('#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()
                })
            }
        );
    });


corrected, but somehow nothing, it got even 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);
                    }
                )
            }
        );
    });

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim Timofeev, 2016-05-30
@webinar

1. the code you provided does not open the modal, but sends an ajax request
2. why renderPartial and not renderAjax?
3. Bind ajax not to the click, but to the "show.bs.modal" or "shown.bs.modal" event (the latter is more reliable), then everything will be ok.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question