init_relate_reply.js 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. $(document).ready(function(){
  2. $("#add_relate_reply").bind("click",function(){
  3. if($("input[name='relate_reply_id[]']").length<9)
  4. {
  5. $.weeboxs.open(LOAD_REPLY_LIST_URL, {boxid:'relate_reply_win',contentType:'ajax',showButton:true, showCancel:true, showOk:true,title:'选择要关联的图文回复',width:550,height:310,type:'',onopen:onOpenRelate,onok:onConfirmRelate,onclose:onCancelRelate});
  6. }
  7. else
  8. {
  9. $.showErr("关联的回复不能超过9条");
  10. }
  11. });
  12. $(".remove_relate").live("click",function(){
  13. $(this).parent().parent().remove();
  14. if($("input[name='relate_reply_id[]']").length==0)
  15. {
  16. $("#relate_table").remove();
  17. $("#relate_table_div").hide();
  18. }
  19. });
  20. $("#ajax_news_form").live("submit",function(){
  21. //改用ajax提交表单
  22. var ajaxurl = $(this).attr("action");
  23. var query = $(this).serialize();
  24. $.ajax({
  25. url: ajaxurl,
  26. data:query,
  27. type: "POST",
  28. success: function(html){
  29. $("#relate_reply_win").find(".dialog-content").html(html);
  30. },
  31. error:function(ajaxobj)
  32. {
  33. }
  34. });
  35. //end
  36. return false;
  37. });
  38. $("#ajax_news_page").find("a").live("click",function(){
  39. //改用ajax提交表单
  40. var ajaxurl = $(this).attr("href");
  41. var query = $("#ajax_news_form").serialize();
  42. $.ajax({
  43. url: ajaxurl,
  44. data:query,
  45. type: "POST",
  46. success: function(html){
  47. $("#relate_reply_win").find(".dialog-content").html(html);
  48. },
  49. error:function(ajaxobj)
  50. {
  51. }
  52. });
  53. //end
  54. return false;
  55. });
  56. });
  57. function onConfirmRelate()
  58. {
  59. var rowsCbo = $("input[rel='relate_reply_id']:checked");
  60. if(rowsCbo.length>0)
  61. {
  62. var relate_table = $("#relate_table");
  63. if(relate_table.length==0)
  64. {
  65. var relate_table = $("<table class='dataTable' id='relate_table'><tr><th>操作</th><th>回复内容</th></tr></table>");
  66. $("#relate_reply_box").append(relate_table);
  67. $("#relate_table_div").show();
  68. }
  69. $.each(rowsCbo,function(i,o){
  70. //alert($(o).val());
  71. if($("#relate_reply_id_"+$(o).val()).length==0)
  72. {
  73. if($("input[name='relate_reply_id[]']").length>=9)
  74. {
  75. close_pop();
  76. return;
  77. }
  78. var row = $("<tr><td><a href='javascript:void(0);' class='remove_relate'>删除</a></td><td><input type='hidden' id='relate_reply_id_"+$(o).val()+"' name='relate_reply_id[]' value='"+$(o).val()+"' />"+$(o).parent().parent().find(".reply_content").html()+"</td></tr>");
  79. $(relate_table).append(row);
  80. }
  81. });
  82. }
  83. close_pop();
  84. }
  85. function onCancelRelate()
  86. {
  87. }
  88. function onOpenRelate()
  89. {
  90. $(document).on('click','#relate_reply_win .pagination a',function(){
  91. var url = $(this).data('url');
  92. if(url){
  93. $.get(url,function(result){
  94. $('#relate_reply_win .dialog-content').html(result);
  95. });
  96. }
  97. });
  98. }