jsp中的彈層

<div class="left">
 <div class="navLeft mv_10" id="navList">
  <a href="/article"
   class="${empty currentCateId ? 'in_block current' : ''}">全部類別</a>
  <c:forEach var="category" items="${categories}">
   <a href="/article?cateId=${category.id}"
    class="${currentCateId == category.id ? 'in_block current' : ''}">${category.name}</a>
  </c:forEach>
 </div>
a href="#" class="ml_5 btnOpH24 h24Silver in_block mr_10 mt_10 js_edit"
  id="addType"> + 添加類別</a>
</div>

 

<!-- 這裏是用來提交的添加類別的 -->
<div class="popLayer" id="editPopupLayer">
 <div class="popTitle clearfix">
  <h1 class="ml_10 mt_15">添加類別</h1>
  <div class="cls">
   <a href="#" class="xx"
    οnclick="hidePopupDiv($('#editPopupLayer')); return false;"></a>
  </div>
 </div>
 <div class="popCon">
  <div class="form center">
   <input type="text" name="newValue" id="commentContent">
  </div>
 </div>
 <form action="" name="commented" method="get">
  <div class="popBtn">
   <a href="#" class="btnOpH24 h24Silver in_block ml_5"
    οnclick="hidePopupDiv($('#editPopupLayer')); return false;">取消</a> <a
    href="#" class="ml_5 btnOpH24 h24Blue in_block" id="saveEdit">提交</a>
  </div>
 </form>
</div>

<script type="text/javascript">
$(function() {
  var clickObj = null;
  $('a.js_edit').click(function() {
   showPopupDiv($('#editPopupLayer'));
   clickObj = $(this);
   $("#commentContent").val();
   
  });

  
  $('#saveEdit').click(
    function() {
     var commentEdit = $("#commentContent").val();
     var url = '/category/add/'+ commentEdit;  
     ajaxPut({
      url : url,
      ok : function(data) {
       
       if (data.status == 'ok') {
        $('#navList').html($('#navList').html()+'<a href="/article?cateId='+data.category.id+'">'+data.category.name+'</a>');
        
       }
      },

      fail : function(data) {
       alert(data.message);
      }
     });
     clickObj.closest('div').find('.js_comment').text(
       $('[name=newValue]').val());
     hidePopupDiv($('#editPopupLayer'));

    });
    });
</script>

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章