jquery - JEditable Passing Custom Parameters -
i trying pass custom parameter(@item.companyid) editable function , tried lots of things. looping in model , need pass 2 parameters. id parameter seems ok. not pass companyid..
@foreach (var item in model) { <div class="edit" data-rel="@item.companyid" id="@item.id">@html.displayfor(modelitem => item.answertext)</div> } <script> $(document).ready(function () { $(".edit").editable("/profile/savemyanswer", { id: "answerid", submitdata : { companyid: function () { return $(this).attr('rel'); } } }); }); </script>
i have solved below.
i have added name attribute contains companyid,
<div class="items" name="@item.companyid" id="@item.id">@html.displayfor(modelitem => item.answertext)</div>change script below
$(document).ready(function () {$(".items").each(function () { var selectedcompanyid = $(this).attr("name"); $(this).editable('/profile/savemyanswer', { id : 'answerid', name : 'answertext', submitdata: function () { return { companyid: selectedcompanyid }; } }); }); });
Comments
Post a Comment