Mui h5 dynamically implements data removal and re-acquisition after data operations, muih5
HTML code
<Ul class = "mui-table-view" id = "OA_task_1">
<Li class = "mui-table-view-cell">
<Div class = "mui-slider-right mui-disabled">
<A class = "mui-btn-bule"> enterprise contact </a>
<A class = "mui-btn-red"> remove </a>
</Div>
<Div class = "mui-slider-handle">
<Div class = "mui-media-body">
<Div class = "mui-pull-left mui-ellipsis pl-name"> mengmeng tiantuan </div>
<P class = "mui-pull-left pl-bule"> enterprise contact </p>
</Div>
<Div class = "mui-media-body">
<P class = "mui-pull-left"> August 1, January 5, 2016 </p>
</Div>
</Div>
</Li>
<Li class = "mui-table-view-cell">
<Div class = "mui-slider-right mui-disabled">
<A class = "mui-btn-col"> enterprise contact </a>
<A class = "mui-btn-red"> remove </a>
</Div>
<Div class = "mui-slider-handle">
<Div class = "mui-media-body">
<Div class = "mui-pull-left mui-ellipsis pl-name"> T-ARA </div>
</Div>
<Div class = "mui-media-body">
<P class = "mui-pull-left"> August 1, January 5, 2016 </p>
</Div>
</Div>
</Li>
</Ul>
Js Code
// Add an enterprise contact
(Function ($ ){
$ ('# OA_task_1'). on ('tap', '. mui-btn-col', function (event ){
Var elem = this;
Var id = this. getAttribute ('id ');
Var li = elem. parentNode. parentNode;
Elem. class = 'mui-btn mui-btn-bule ';
Mui. confirm ('Are you sure you want to add this employee as the enterprise contact? ',' Hint ', btnArray, function (e ){
If (e. index = 0 ){
Var ajaxUrl = getajaxUrl ();
Var url = ajaxUrl [0] ['nativeip'] + "/mobile/labor/iscontacts ";
Mui. ajax (url ,{
Data :{
Id: id,
Type: "1"
},
DataType: 'json', // The server returns json data
Type: 'post', // HTTP request type
Timeout: 10000, // The timeout value is set to 10 seconds;
Success: function (data ){
Var result = eval (data );
Result = eval (result );
If (result [0] ['isok']) {
$. SwipeoutClose (li );
Var divp = "<p class = 'mui-pull-left pl-bule'> enterprise contact </p>"
Var contact = "<a id =" + result [0]. newlabour. id + "class = 'mui-btn mui-btn-bule'> enterprise contact </a>"
Li. innerHTML = '<div class = "mui-slider-right mui-disabled" id = "">' + contact + '<a id = "' + result [0]. newlabour. id + '"class =" mui-btn-red "> remove </a> </div> <div class =" mui-slider-handle "> <div class =" mui-media-body "> <div class =" mui-pull-left mui-ellipsis pl-name ">' + result [0 ]. user. nickname + '</div>' + divp + '</div> <div class = "mui-media-body"> <p class = "mui-pull-left"> '+ result [0]. newlabour. updatetime + '</p> </div>'
Mui. toast ('this employee has become an enterprise contact! ');
}
},
Error: function (xhr, type, errorThrown ){
// Exception handling;
Console. log (type );
}
});
}
Else {
SetTimeout (function (){
$. SwipeoutClose (li );
}, 0 );
}
});
});
Var btnArray = ['OK', 'cancel'];
}) (Mui );
// Remove the enterprise contact
(Function ($ ){
$ ('# OA_task_1'). on ('tap', '. mui-btn-bule', function (event ){
Var user = JSON. parse (plus. storage. getItem ("user "))
Var elem = this;
Var id = this. getAttribute ('id ');
Var li = elem. parentNode. parentNode;
Mui. confirm ('Are you sure you want to cancel this employee as an enterprise contact? ',' Hint ', btnArray, function (e ){
If (e. index = 0 ){
Var ajaxUrl = getajaxUrl ();
Var url = ajaxUrl [0] ['nativeip'] + "/mobile/labor/iscontacts ";
Mui. ajax (url ,{
Data :{
Id: id,
Type: "0"
},
DataType: 'json', // The server returns json data
Type: 'post', // HTTP request type
Timeout: 10000, // The timeout value is set to 10 seconds;
Success: function (data ){
Var result = eval (data );
Result = eval (result );
If (result [0] ['isok']) {
$. SwipeoutClose (li );
Var divp = ""
Var contact = "<a id =" + result [0]. newlabour. id + "class = 'mui-btn mui-btn-col'> enterprise contact </a>"
Li. innerHTML = '<div class = "mui-slider-right mui-disabled" id = "">' + contact + '<a id = "' + result [0]. newlabour. id + '"class =" mui-btn-red "> remove </a> </div> <div class =" mui-slider-handle "> <div class =" mui-media-body "> <div class =" mui-pull-left mui-ellipsis pl-name ">' + result [0 ]. user. nickname + '</div>' + divp + '</div> <div class = "mui-media-body"> <p class = "mui-pull-left"> '+ result [0]. newlabour. updatetime + '</p> </div>'
Mui. toast ('the enterprise contact is removed successfully! ');
}
},
Error: function (xhr, type, errorThrown ){
// Exception handling;
Console. log (type );
}
});
}
Else {
SetTimeout (function (){
$. SwipeoutClose (li );
}, 0 );
}
});
});
Var btnArray = ['OK', 'cancel'];
}) (Mui );
Effect