2016-06-16 4 views
0

Ich fragte mich, ob es eine Möglichkeit gibt, das "Klick" -Ereignis des EditorFor auslösen, wenn ich auf dem Glyphicon-Symbol (oder um) drücken?Holen Sie sich den onclick von Glyphicon in EditorFor

Hier ist der Code:

<div class="col-md-10"> 
@Html.EditorFor(model => model.FullName, new { htmlAttributes = new { @class = "form-control" } }) 
<span style="font-size:1.5em;" id="f1" class="glyphicon glyphicon-question-sign form-control-feedback"></span> 
@Html.ValidationMessageFor(model => model.FullName, "", new { @class = "text-danger" }) 

</div> 

Dank

+0

Ok fand die Antwort, die es wirklich hilft: http: // sta ckoverflow.com/questions/29047573/click-event-on-glypicon – Nostradamus

Antwort

1

Zuerst eine ID an den EditorFor geben:

@Html.EditorFor(model => model.FullName, new { htmlAttributes = new { @class = "form-control", @id = "e1" } }) 
    <span style="font-size:1.5em;" id="f1" class="glyphicon glyphicon-question-sign form-control-feedback"></span> 

Und dann jQuery wie folgt: nur

$("#f1").bind("click", (function() { 
    $("#e1").trigger("click"); 
})); 
Verwandte Themen