oscar11

t2

Oct 29th, 2015
11
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <script type="text/javascript">
  2.  
  3. $(function(){
  4. var oldContainer
  5. var group = $("ol.nested_with_switch, ol.hotel_list").sortable({
  6. group: 'serialization',
  7. afterMove: function (placeholder, container) {
  8. if(oldContainer != container){
  9. if(oldContainer)
  10. oldContainer.el.removeClass("active");
  11.  
  12. container.el.addClass("active");
  13. oldContainer = container;
  14. }
  15. },
  16. onDrop: function (item, container, _super) {
  17.  
  18. var data = group.sortable("serialize").get();
  19.  
  20. var jsonString = JSON.stringify(data, null, ' ');
  21. console.log(jsonString);
  22. $('#serialize').val(jsonString);
  23. container.el.removeClass("active")
  24. _super(item)
  25. }
  26. });
  27.  
  28. $('#add_hotel').click(function(){
  29. var hotel_type_number = $.trim($('#hotel_type_number').val());
  30. if(hotel_type_number!='' && typeof hotel_type_number != 'undefined' ){
  31. var hotel_type_id = $('#hotel_type').val();
  32.  
  33. var text = $("#hotel_type option:selected").text();
  34. $('#hotel_list').append('<li class="remove_hotel'+hotel_type_id+'" data-id="'+hotel_type_id+'" data-name="'+text+'" data-number="'+hotel_type_number+'">'+text+' '+hotel_type_number+'<div class="hotel-remove"><a href="#" class="remove'+hotel_type_id+'">X</a></div><ol></ol></li>');
  35. $('.remove'+hotel_type_id).click(function(e){
  36. e.preventDefault();
  37. $('.remove_hotel'+hotel_type_id).remove();
  38. });
  39. }
  40. else{
  41. alert('Please insert Hotel Type Number');
  42. $('#hotel_type_number').focus();
  43. }
  44. });
  45.  
  46. $('#tes').submit(function(){
  47. if($('#serialize').val()==''){
  48. alert('Input konsumen hotel');
  49. return false;
  50. }
  51. });
  52.  
  53. });
  54.  
  55. </script>
RAW Paste Data