ajax - Get value with JQuery value from Table -


i have view passes @model ienumerable<webapplication2.entities.movie> dumps out list of movie's in table me.

i trying value of item.id.

the following code gives me text input in item-field, not sure how manipulate location value of input above it.

var name1 = $field.find(":input:first").val(); 

here entire jquery overview

<script>         $(document.documentelement)         .on("click", "span.item-display", function (event) {             $(event.currenttarget)                 .hide()                 .next("span.item-field")                 .show()                 .find(":input:first")                 .focus()                 .select();         })         .on("focusout", "span.item-field", function (event) {             console.log("this log");             var $field = $(event.currenttarget),             $display = $field.prev("span.item-display");             $display.html($field.find(":input:first").val());             $display.show();             $field.hide();              var name1 = $field.find(":input:first").val(); // <-- gets blue whales              $.post(                 '@url.action("updatetitle", "movie")',                  {                      'id': '1', // <-- want "value"                      'name': name1                  },                 function (data) { },                 "json"             );         });     </script> 

edit: friend trying give me helping hand, added code

<span style="visibility:hidden;">@html.displayfor(modelitem => item.id)</span> 

which sits right on area currenttarget at, snippet looks like

<td class="col-lg-2">        <span style="visibility:hidden;">@html.displayfor(modelitem => item.id)</span>             <span class="item-display">                    <span style="font-size: 17px;">@html.displayfor(modelitem => item.name)</span>             </span>           <span class="item-field">                    @html.editorfor(modelitem => item.name)           </span>  </td> 

now should able somehow find value (item.id).

try this

to model in jquery variable

var dataviewmodel = @html.raw(json.encode(model)); 

cycle them

dataviewmodel.each(function(index){     //get property     var id=dataviewmode[index].id; }); 

update

http://jsfiddle.net/rnv8m/1/

alert($("#text2").prev("input:text:first").val());  <div>     <input type="text" id="text1" value="abc"/>     <input type="text" id="text2" value="def"/> </div> 

replace $("#text2") $(event.currenttarget)


Comments

Popular posts from this blog

c++ - OpenCV Error: Assertion failed <scn == 3 ::scn == 4> in unknown function, -

php - render data via PDO::FETCH_FUNC vs loop -

The canvas has been tainted by cross-origin data in chrome only -