LinkedNestBlog

[jQuery] selectable을 이용, 드래그 영역의 데이터 가져오기

by jinwon lee
[jQuery] selectable을 이용, 드래그 영역의 데이터 가져오기

Example : 
function initEvent() {

  var dragData="";

 /* 등록된 데이터가 없는 행의 시간상태 Bar를 드레그하는 경우 적용 */

 $("tr[class$='selectableFc']").selectable({
      filter: ".ui"
  ,selected: function(event, ui) {
   var selectedMap = new HashMap();
   $(".ui-selected", this).each(function(){
    $(this).removeClass("ui-selected");
    selectedMap.put($(this).attr("id"), true);
   });  
   for(var i=selectedMap.keyIterator(); i.hasNext(); ) {
    var key = i.next();
    var value = selectedMap.get(key);
    selectedKeys.push(key);
    dragData += key+";";
   }
   $("#dragData").val(dragData);
  }
  ,stop: function(event, ui) {
   dragFCReserv();
  }

 });
 $("input[id='groupName']").bind('focus', inputFocusHandler);
 $("input[id='groupName']").bind('blur', inputBlurHandler);

    }
/* 드래그 이벤트 발생 시 시설물 예약 팝업 창 출력*/
 dragFCReserv = function(){
  var grantType = $("#grantType").val();
  var dragData = $("#dragData").val();
  var dragArray = new Array();
  var dragArray2 = new Array();
  var dragArray3 = new Array();
  var fcId = new Array();
  var reservHour = new Array();
  var reservDate = "";
  dragArray = dragData.split(";");
  var length = dragArray.length-2;

  for(var i=0; i<dragArray.length-1;i++){
   dragArray2 = dragArray[i].split("_");
   for(var j=0;j<dragArray2.length;j++){
    if(j%2==0){  fcId.push(dragArray2[j]); }
    else{//reservHour.push(dragArray2[j]);     //  j가 짝수이면 facilityIdj가 홀수이면 startTime
     dragArray3 = dragArray2[j].split("/"); 
     reservHour.push(dragArray3[0]);
     reservDate = dragArray3[1];
    } 
   }
  }    
  var facilityId=fcId[0];
  var startHour=reservHour[0];
  var endHour=reservHour[length];

  if(facilityId==""||facilityId==undefined){
//   location.href = "/neo/modules/fc/fcReservList.mvc?facilityId="+$("#facilityId").val()+"&grantType="+grantType;
  }else{ 
   var url = "/neo/modules/fc/fcReservRequest.mvc?facilityId="+facilityId+"&startHour="+startHour+"&endHour="+endHour+"&startDate="+reservDate;

   var data = {
     url: url,
     title: "::: 시설물 예약 :::",
     top: 100,
     left: 100,
     width: 819,
     height: 315,
//     param:{ facilityId:facilityId, startHour:startHour, endHour:endHour },
     onClose: closeHandler
   }  
   $.modal(data); 
  } 
 }