to intercept a string; string concatenation; dynamically loop to add elements:
Get Current button:
{data:NULL, Render:function(data, type, row) {varLoginName = $ ("#loginName"). Val (); vardiv = $ ("<div class= ' Btn-group ' ></div>"); varButton1 = $ ("<button role= ' Download ' value= '" + row[5] + "' name= ' Download ' class= ' btn btn-xs btn-info Glyphicon Glyph Icon-save ' title= ' Download ' ></button> '); varButton2 = $ ("<button role= ' pass ' name= ' edit '" + "data-templatename= '" + row[1] + "'" + "Data-reportsumid = ' "+ row[0] +" ' "+" data-cycle= "" + row[2 "+" ' "+" data-sumpeople= "+ row[4] +" ' "+" class= ' B TN btn-xs btn-info glyphicon glyphicon-edit ' title= ' circulated ' ></button> '); if(row[4]!=loginname&&row[6]== ' 1 ') {//rolled up but not a person who is a total user cannot downloadButton1.attr ("Disabled",true); } if($ ("#ifPassRole"). val () = = "No") {button2.attr ("Disabled",true); } div.append (button1). Append (Button2); returnDiv[0].outerhtml;}
Showpassmodel:function(e) {varViewself = This;//Gets the button object that cannot be directly fetched to the current action button and needs to be converted. var $btn =$ (e.currenttarget); //Get current action button vartemplatename = $btn. Data (' templatename '); //Gets the current button bound data varReportsumid = $btn. Data (' Reportsumid '); $.ajax ({type:"POST", url:$ $ctx+ "/reportresultquery/queryusersbyroleid", data:{Roleid:"480"}, Success:function(Result) {$ ("#div-passname"). HTML (""); varHtmlcontent = ""; $.each (Result.data,function(I,item) {//dynamic Loop adding elementsHtmlcontent + = ' <input name= "Checkeduser" type= "checkbox" value= "' +item.ssoid+ '"/> ' + " " +item.username+ ' </br> '; }); $ (htmlcontent). AppendTo ($ ("#div-passname")); } }); $("#passModal"). Modal ("show")); Viewself.savefunction (Templatename,reportsumid); //Passing Parameters},
Savefunction:function(Templatename,reportsumid) {$ ("Button[role= ' savefunction ']"). Click (function(){ varSTR1 = ""; $("Input[name= ' Checkeduser ']:checked"). each (function() {str1+= $( This). Val () + ",";//checkbox Gets the selected data $.each (); }); $.ajax ({type:"POST", url:$ $ctx+ "/reportresultquery/savepassuser", data:{readUserId:str1.substring (0, Str1.length-1),//intercept string string.substring ();templatename:templatename, Reportsumid:reportsumid}, success:function(Result) {$ ("Button[role= ' savefunction ']"). Unbind ("click");//Unbind the button to prevent multiple pop-up $.unbind ("click"); } }); $("#passModal"). Modal ("Hide"); });}
jquery get Current button, intercept string, string concatenation, dynamic loop add element