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.

  1. i have added name attribute contains companyid,

    <div class="items" name="@item.companyid" id="@item.id">@html.displayfor(modelitem => item.answertext)</div> 
  2. 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

Popular posts from this blog

node.js - Using Node without global install -

How to access a php class file from PHPFox framework into javascript code written in simple HTML file? -

java - Null response to php query in android, even though php works properly -