I want to add a modal in my project, so I folowed this Question
but when I click on my Ajouter demander
button nothing appears(my modal dosn't appear). This my code :
Partial View :
@model pfebs0.Models.DEMANDE
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h3 id="myModalLabel">Ajouter un demande</h3>
</div>
<div>
@using (Html.BeginForm()) {
@Html.AntiForgeryToken()
@Html.ValidationSummary(true)
<div class="modal-body">
<div class="controls">
<label for="Citoyen_CIN" >CIN(Nom) du demandeur</label>
@Html.DropDownList("CIT_CIN", String.Empty)
@Html.ValidationMessageFor(model => model.CIT_CIN)
</div>
<div class="form-group">
<label for="Description">Description d'offre</label>
@Html.TextAreaFor(model => model.DESCREPTION)
@Html.ValidationMessageFor(model => model.DESCREPTION)
</div>
<div class="form-group">
<label for="Observation">Observation</label>
@Html.EditorFor(model => model.OBSERVATION)
@Html.ValidationMessageFor(model => model.OBSERVATION)
</div>
<div class="modal-footer">
<button type="submit" class="btn btn-default">Valider</button>
<button type="reset" class="btn btn-default">Fermer</button>
</div>
</div>
}
</div>
Details View (I puted only Modal code to avoid having long code ) :
<button class="btn btn-primary CreateDM" data-id="@Model.CIT_CIN">Ajouter demander</button>
<div class="modal hide fade in" id="CreateDM">
<div id="CreateDM-container"></div>
</div>
<script type="text/javascript">
$(document).ready(function () {
$('.createDM').click(function () {
var url = "/Citoyen/CreateDM"; // the url to the controller
var id = $(this).attr('data-id'); // the id that's given to each button in the list
$.get(url + '/' + id, function (data) {
$('#CreateDM-container').html(data);
$('#CreateDM').modal('show');
});
});
});
</script>
CreateDM action :
[HttpGet]
public ActionResult CreateDM(decimal id)
{
var newDM = new DEMANDE();
newDM.CIT_CIN = id;
return PartialView("_CreateDM", newDM);
}
So what's wrong in my code ?