jquery get Current button, intercept string, string concatenation, dynamic loop add element

Source: Internet
Author: User

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+ '"/> ' + "&nbsp;&nbsp;" +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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.