重建实际的FullCalendar eventClick函数

时间:2017-05-01 13:05:06

标签: javascript jquery html ajax fullcalendar

我有一个完整的日历日历,其中点击事件在功能中具有甜蜜警报2弹出窗口。弹出框具有多个使用甜蜜警报HTML功能构建的下拉菜单。这是代码的一个例子,     eventClick:function(calEvent,jsEvent,view,date){         var clickValue = calEvent.description;         if(clickValue!=' OWEDVALUE'){             var btn =" button&#34 ;;             drop = drop.replace(" select-style-purple"," select-style-green");             options = options.replace(" select-style-purple"," select-style-green");             var title = calEvent.title.replace(" \ n","< br />");             SwaI位({                 title:moment(calEvent.start).format(" MM / DD / YYYY"),                 输入:' info',                 inputClass:' select-style-green',                 inputValue:calEvent.teachNum,                 html:title +'< br />' +                     '注意:' + calEvent.description +'< br />< br />选择新教师:< br />< br />' +选项+'< p>< / p>选择新服务:< br />< br />' +掉落+                     '< br />< br />< div style =" border:2px solid green;" >更新时间:' +                     '< input type =" text" autofocus id =" newHours" style =" display:block!important;"类="甜警报输入" />' +                     '<输入类型="隐藏" ID =" oldHours"值="' + calEvent.hours +'" />< / DIV>' +                     '< button type ="' + btn +'" ID =" btnA"值="' + calEvent.id +'" style =" background-color:#D46752!important;" class =" sweet-alert2-button">删除记录< / button> ' +                     '< button type ="' + btn +'" ID =" btnB"值="' + calEvent.id +'" class =" sweet-alert2-button">更新记录< / button> ' +                     '< button type ="' + btn +'" ID =" btnC" style =" background-color:#B9B9B9!important;"类="甜警报2按钮">取消< /按钮>&#39 ;,                 showConfirmButton:false             });             $(this).css(' border-color',' red');         } 这是javascript var中内置的一个下拉框的示例。 options ='< select id =" teacherDrop"类="选择式 - 绿">&#39 ;; for(var i = 0; i< record_array.length; i ++){     options + ='< option value ="' + record_array [i] .teachNum +'" &#39 ;;     if(record_array [i] .teachName == data [0] .teacher)        options = options +'选定="选择" >' + record_array [i] .teachName +' TEST< / option>&#39 ;;     其他         options = options +'>' + record_array [i] .teachName +' TEST< / option>&#39 ;; } options + ='< / select>&#39 ;; 我想做的是在每次点击事件ajax调用之后重建下拉列表(更新所选值),所以我需要重建实际的eventClick函数而不是eventSources。我尝试过多件事无济于事。 以下是从Sweet-Alert中按下一个提交按钮时调用的函数。 $(文件).on('点击',"#btnB",function(){   if($ .isNumeric($(" #newHours")。val())){     var qString;     qString =" id =" + this.value;     qString + ="& teacherId =" + $("#teacherDrop")。val();     qString + ="& hours =" + $(" #newHours")。val();     qString + ="& service =" + $("#serviceDrop")。val();     $就({         键入:" POST",         url:" _data_ManageHomebound_Students.aspx?qt = updateStudentRecord",         数据:qString,         async:false,         成功:函数(数据){             data = JSON.parse(data);             swal.close();             $('#calendar')。fullCalendar(' removeEvents',data [0] .id);             $("#calendar")。fullCalendar(' renderEvent',{                 标题:"服务类型:" + data [0] .serviceType +" \ nTeacher:" + data [0] .teacher +" \ nHours:" + $(" #newHours")。val(),                 id:data [0] .id,                 start:data [0] .start,                 结束:数据[0] .start,                 allDay:data [0] .allDay,                 描述:data [0] .description,                 老师:数据[0]。老师,                 homeBoundPaidID:data [0] .homeBoundPaidID,                 teachNum:data [0] .teachNum,                 serviceType:data [0] .serviceType,                 颜色:'绿色',                 textColor:' black'             },false);             $('#ant')。addClass('动画zoomInDown')。one(' webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend',function(){                 $(this).removeClass(' animated zoomInDown');             });             //在这里,我将重建服务类型下拉列表并尝试重新创建所有点击事件。             var选项;             options ='< select id =" teacherDrop"类="选择式 - 绿">&#39 ;;             for(var i = 0; i< record_array.length; i ++){                 options + ='< option value ="' + record_array [i] .teachNum +'" &#39 ;;                 if(record_array [i] .teachName == data [0] .teacher)                     options = options +'选定="选择" >' + record_array [i] .teachName +' REBUILT< / option>&#39 ;;                 其他                     options = options +'>' + record_array [i] .teachName +' REBUILT< / option>&#39 ;;             }             options + ='< / select>&#39 ;;             var temp = $("#hoursGiven")。val();             if($(" #newHours")。val()> = $(" #oldHours")。val()){                   temp = parseFloat(temp)+(parseFloat($(" #newHours")。val()) - parseFloat($("#oldHours")。val()));             } else {                 temp = parseFloat(temp) - (parseFloat($("#oldHours")。val()) - parseFloat($(" #newHours")。val()));             }             $("#hoursGiven&#34)。VAL("&#34);             $("#hoursGiven&#34)。VAL(温度);             $("#hoursOwed")。val(parseFloat($(" #totHoursNeeded")。val()) - parseFloat(temp))         }     });   } else {     sweetAlert({         标题:"糟糕!",         文字:"请确保付费率是数字。 \ n请修改表单然后重试。",         输入:"错误"     });     返回false;   } }); 因此,在Ajax成功之后,我重建了包含Sw​​eet-Alert下拉信息的options var。这就是我需要重建所有点击事件以使用更新的代码(options var)的地方。这样做的目的是我试图让下拉列表具有最近使用的项目(教师等等)的预选值。

0 个答案:

没有答案