The first, less edited, is edited directly on that piece of content, losing focus is done
A few days ago when editing a box, you need to modify only one State
Edit Role function Edittr ($this) { thattd=$ ($this). parent (). prev (); value=$.trim (thattd.html ()); Str= ' <input type= "text" id= "editing" value= "' +value+ '" > "; thattd.html (str); Thattd.find (' input '). focus ();} Edit completed $ (document). on (' Blur ', ' #editing ', function() {value=$ (). val (); $ (this). parent (). HTML ( value); Layer.msg (' Edit User Role complete ', {icon:1,time:1000})})
The second, the entire line is editable implementation
Template file:lists array for the existing column, JS file processing more, Not all of them, just put an edit processing, add is to combine a string append come over, delete the direct access to the ID after the AJAX delete is Good.
1 <tbody>2 <volistname= "lists"ID= "v">3 <TR>4 <TD>{$v. id}</TD>5 <TD>{$v. name}</TD>6 <TD>{$v. sort}</TD>7 <TD><ifcondition= "$v [' default '] eq 1">YES<Else/>NO</if></TD>8 <TDclass= "actiontd"><spanclass= "action edit">Edit</span> <spanclass= "action del">Delete</span></TD>9 </TR>Ten </volist> one <TRID= "nowtr"> a <TDID= "swid"></TD> - <TD><inputID= "swname"type= "text"placeholder= "please fill in the software name" /></TD> - <TD><inputID= "swsort"type= "text"class= "small"placeholder= "sort" /></TD> the <TD> - <SelectID= "swdefault"> - <optionvalue= "1">Selected by default</option> - <optionvalue= "0">Default not selected</option> + </Select> - </TD> + <TDclass=""><aclass= "btn btn-success"ID= "swadd">Add to</a></TD> a </TR> at </tbody>
1$ (' Table '). on (' click ', ' Span.edit,span. Mjedit ',function(){2 varPre= ";3 vartdlist=$ ( this). parent (). (). find (' TD ');4 if($( this). attr (' Class ') = = ' Action Mjedit '){5Pre= ' MJ ';6 }7$ (' # ' +pre+ ' swid '). html (tdlist.eq (0). HTML ());8$ (' # ' +pre+ ' Swname '). val (tdlist.eq (1). HTML ());9$ (' # ' +pre+ ' Swsort '). val (tdlist.eq (2). HTML ());Tendefaultx= ($.trim (tdlist.eq (3). html ()) = = ' YES ')? 1:0; one$ (' # ' +pre+ ' Swdefault '). Val (defaultx); aTypename=tdlist.eq (4). HTML (); -$ ("#MJtype option:contains ('" +typename+ "')"). attr ("selected",true); -$ (' # ' +pre+ ' swadd '). html (' edit '); theLayer.msg (' please edit below '); -})//Edit End
JS file on the selector has Span.edit,span. Mjedit are two places that trigger edits, and then do a slightly different processing by attr (' class '), using the pre variable to Differentiate. It's not much of a relationship Here.
Delete page content using jquery edit, two ways