mercredi 8 mars 2017

Set default checkbox using jquery not working inside modal bootstrap

I have a button, when it's clicked, bootstrap modal appears to update some information and set the information that recorded in database before. But when i want to set checkbox inside bootstrap modal using jQuery, it doesn't work.

<div class="modal fade" id="modalUpdate" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog">
    <div class="modal-content">
        <div class="modal-header bgm-blue">
            <h4 class="modal-title text-center">Share Link</h4>
        </div>
        <div class="modal-body">
            <form data-request="onUpdateLink">
                <div class="form-group">
                    <label class="">Link</label>
                    <input type="text" class="form-control" id="modal-link" value="" name="link"/>
                </div>
                <div class="form-group">
                    <label class="">Message</label>
                    <textarea class="summernote" name="message" id="modal-message"></textarea>
                </div>
                <div class="form-group">
                    <label class="checkbox" for="modal-published">
                        <input type="checkbox" name="published" id="modal-published" data-toggle="checkbox"
                               class="custom-checkbox">
                        Show
                    </label>
                </div>
                <input type="text" value="" id="modal-id" name="id" hidden/>
                <button type="submit" class="btn btn-primary btn-lg btn-block" href="#">Update</button>
            </form>
        </div>
    </div>
</div>

Here is my jQuery code:

function detail(data) {
    var row = jQuery.parseJSON(data.result);

    $('.summernote-notes').summernote({
        height: 200,
        tabsize: 2,
        direction: 'rtl'
    });

    $('#modal-id').val(row.id);
    $('#modal-link').val(row.link);
    $('#modal-message').summernote('code', row.content);
    $('#modal-published').prop('checked', row.published);

    $("#modalUpdate").modal();
}

Any advice would be appreciated. Thanks!




Aucun commentaire:

Enregistrer un commentaire