Error Calling Jquery function

3

I have the following button:

<button class="btn btn-default details" data-id="@fornecedores.Codigo"><i class="glyphicon glyphicon-file"></i></button>

On the same page I have the following script:

$(document).ready(function () {
    $(".details").click(function () {
        var id = $(this).attr("data-id");
        $("#modal").load("Detalhes?id=" + id, function () {
            $("modal").modal('show');
        })
    });
})

When I click Click it looks at the message that appears:

ThisexampleItookthislink: link

    
asked by anonymous 10.09.2015 / 21:23

3 answers

4

In order to work, you need to give the include js of twitter bootstrap 3.

As you are using Asp.Net MVC, you can use bundle , in the file BundleConfig.cs you set it like this:

bundles.Add(new ScriptBundle("~/bundles/bootstrapjs").Include(
    "~/Scripts/bootstrap.min.js"));

bundles.Add(new StyleBundle("~/Content/bootstrapcss").Include(
    "~/Content/bootstrap.min.css",
    "~/Content/bootstrap-responsive.min.css"));

Then in your html you call bundles created like this:

@Styles.Render("~/Content/bootstrapcss")
@Scripts.Render("~/bundles/bootstrapjs")

Remembering that the files of css and js of bootstrap should be in the correct folders, you can put them manually or use NuGet .

Or you can use it like this:

<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"integrity="sha256-Sk3nkD6mLTMOF0EOpNtsIry+s1CsaqQC1rVLTAy+0yc= sha512-K1qjQ+NcF2TYO/eI3M6v8EiNYZfA95pQumfvcVrTHtwQVDG+aHRqLi/ETn2uB+1JqwYqVG3LIvdm9lj6imS/pQ==" crossorigin="anonymous"></script>
    
10.09.2015 / 21:25
3

The console says that the function was not defined because modal () is not a native function of Jquery, but rather of Bootstrap.js.

So, if you do not have the bootstrap.js file being called a script tag, the function will not exist.

    
10.09.2015 / 21:36
0

Include the bootstrap file, without instantiating it, it does not recognize if there is conflict because of other libraries, do not forget to use jQuery noConflict ().

    
10.09.2015 / 23:02