Search code examples
ajaxlaravelbootstrap-modalsimplemodal

My script modal is not working


Im trying to test my bootstrap modal in my laravel project but its nothing response.

@extends('layouts.admin')
     @section('body')
    <div class="col-lg-4 col-md-6">
        <a href="#" class="block padder-v hover" id="btnAgenda">
          <button type="button" class="btn btn-info btn-block">Block Button</button>
        </a>
    </div>
<div class="modal fade" id="modalAgenda" tabindex="-1" role="dialog" aria-labelledby="member" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                Agendaaa asd
            </div>
        </div>
    </div>
</div>

<script>
    $("#btnAgenda").on("click",function(){
        $("#modalAgenda").modal("show");
    });
</script>

Why my script its not working ?


Solution

  • ANSWER - Please mark if correct

    From what @Shehary said above.

    index.html

    <a href="#" class="block padder-v hover" id="btnAgenda">
              <button type="button" class="btn btn-info btn-block">Block Button</button>
            </a>
    <div class="modal fade" id="modalAgenda" tabindex="-1" role="dialog" aria-labelledby="member" aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    Agendaaa asd
                </div>
            </div>
        </div>
    

    jquery

    $("#btnAgenda").on("click",function(){
        $("#modalAgenda").modal("show");
    });
    

    2 Possible Reasons, 1- as suggested by @KótaPéter check jQuery (comes first) and bootstrap.js exist or not, 2- Is your script DOM ready? code in question works properly. so try with DOM ready http://jsfiddle.net/cemyzefd/