| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596 |
- $(function(){
- var item_id = $("#item_id").val();
- $('#edit-cat').modal({
- "backdrop":'static'
- });
- getList();
- function getList(){
- $.get(
- "?s=/home/member/getList",
- { "item_id": item_id },
- function(data){
- $("#show-cat").html('');
- if (data.error_code == 0) {
- json = data.data;
- console.log(json);
- for (var i = 0; i < json.length; i++) {
- cat_html ='<a class="badge badge-important single-cat" data-username="'+json[i].username+'" >'+json[i].username+' x</a>';
- $("#show-cat").append(cat_html);
- };
- };
-
- },
- "json"
- );
- }
- //保存
- $("#save-cat").click(function(){
- var username = $("#username").val();
- $.post(
- "?s=/home/member/save",
- {"username": username ,"item_id": item_id },
- function(data){
- if (data.error_code == 0) {
- $("#username").val('');
- alert("保存成功!");
- }else{
- alert(data.error_message);
- }
- getList();
- },
- "json"
- );
- return false;
- });
- //删除
- $('#show-cat').delegate('.single-cat','click', function(){
- var username = $(this).attr("data-username");
- if (username) {
- $.post(
- "?s=/home/member/delete",
- { "username": username, "item_id" :item_id },
- function(data){
- if (data.error_code == 0) {
- alert("删除成功!");
- getList();
- }else{
- alert("删除失败!");
- }
- },
- "json"
- );
- }
- return false;
- });
- $(".exist-cat").click(function(){
-
- window.location.href="?s=/home/item/show&item_id="+item_id;
- });
- });
|