Pass the data-id="@ milestones.code" to a modal

2

My system should work as follows:

By clicking on the highlighted red button in the image below

Itopensthismodalhere:

Thisisalreadyhappening,butnowIneedtoclickonthefirstimage,itwilltakedata-id="@milestones.Codigo" and save it in the CodigoMilestone field.

Button that calls the modal Activity:

<button class="btn btn-default AddAtividade" data-id="@milestones.Codigo"><i class="glyphicon glyphicon-plus"></i></button>

Script that opens the modal:

$(document).ready(function () {

$(".AddAtividade").click(function () {
    $("#modal").load("AddAtividade", function () {
        $(".modal").modal();
    })
}); 
})

How can I do this?

    
asked by anonymous 07.10.2015 / 03:32

1 answer

3

I could do something like this.

$(document).ready(function () {

$(".AddAtividade").click(function () {

    var codigoMilestone = $(this).attr("data-id");

    $("#modal").load("AddAtividade", function () {

        $("#meuInputId").val(codigoMilestone);

        $(".modal").modal();
    })
}); 
})
    
07.10.2015 / 15:05