如何在jquery对话框中禁用更新按钮

时间:2013-04-19 06:46:57

标签: jquery jquery-ui-dialog

这是我的完整日历。当我在特定事件中点击完整日历时,对话框屏幕将会打开。

这是我的剧本:

 var date = new Date();
    var d = date.getDate();
    var m = date.getMonth();
    var y = date.getFullYear();

    var calendar = $('#calendar').fullCalendar({
        theme: true,
        header: {
            left: 'prev,next today',
            center: 'title',
            right: 'month,agendaWeek,agendaDay'
        },

        eventClick: updateEvent,
        selectable: true,
        selectHelper: true,
        select: selectDate,
        editable: true,
        events: "JsonResponse.ashx",
        eventDrop: eventDropped,
        eventResize: eventResized,
        eventRender: function(event, element) {
            //alert(event.title);
            element.qtip({
                content: event.projectdescription,
                position: { corner: { tooltip: 'bottomLeft', target: 'topRight'} },
                style: {
                    border: {
                        width: 1,
                        radius: 3,
                        color: '#2779AA'

                    },
                    padding: 10,
                    textAlign: 'center',
                    tip: true, // Give it a speech bubble tip with automatic corner detection
                    name: 'cream' // Style it according to the preset 'cream' style
                }

            });
        }

    });

});

当单击evnt时,将调用“更新事件”功能,该对话框将打开,因为我在某些secanrio中有更新按钮,我想禁用它。

var currentUpdateEvent;
var addStartDate;
var addEndDate;
var globalAllDay;

function updateEvent(event, element) {
    //alert(event.description);

    if ($(this).data("qtip")) $(this).qtip("destroy");

    currentUpdateEvent = event;

    $('#updatedialog').dialog('open');
    $("#eventId").val(event.id);
    $("#lblprjnumber").text(event.projectnumber);
    $("#lblprjname").text(event.projectname );
    $("#lblprjdesc").text(event.projectdescription);
    $("#lblMonday").val( event.Monday);
    $("#lblTuesday").val(event.Tuesday);
    $("#lblwednesday").val(event.Wednesday);
    $("#lblthursday").val(event.Thursday );
    $("#lblfriday").val(event.Friday);
    $("#lblsaturday").val(event.Saturday);
    $("#lblsunday").val( event.Sunday);


    $("#eventStart").text("" + event.start.toLocaleString());

    if (event.end === null) {
        $("#eventEnd").text("");
    }
    else {
        $("#eventEnd").text("" + event.end.toLocaleString());
    }

}

对于您的参考我也发布了“更新对话框”

$(document).ready(function() {

    // update Dialog
    $('#updatedialog').dialog({
        autoOpen: false,
        width: 470,
         buttons: {
            "update": function(evt) 
            {
                               //alert(currentUpdateEvent.title);
                var eventToUpdate = {
                    id : currentUpdateEvent.id,
                    projectnumber : $("#lblprjnumber").text(),
                    projectname : $("#lblprjname").text(),
                    projectdescription : $("#lblprjdesc").val(),
                    Monday : $("#lblMonday").val(),
                    Tuesday : $("#lblTuesday").val(),
                    Wednesday : $("#lblwednesday").val(),
                    Thursday : $("#lblthursday").val(),
                    Friday : $("#lblfriday").val(),
                    Saturday : $("#lblsaturday").val(),
                    Sunday : $("#lblsunday").val()

                };

                if (checkForSpecialChars(eventToUpdate.title) || checkForSpecialChars(eventToUpdate.description)) {
                    alert("please enter characters: A to Z, a to z, 0 to 9, spaces");
                }
                else {
                    PageMethods.UpdateEvent(eventToUpdate, updateSuccess);
                    $(this).dialog("close");
                    currentUpdateEvent.projectnumber = $("#lblprjnumber").val();
                    currentUpdateEvent.projectname = $("#lblprjname").val();
                    currentUpdateEvent.projectdescription = $("#lblprjdesc").val();
                    currentUpdateEvent.Monday = $("#lblMonday").val();
                    currentUpdateEvent.Tuesday = $("#lblTuesday").val();
                    currentUpdateEvent.Wednesday = $("#lblwednesday").val();
                    currentUpdateEvent.Thursday = $("#lblthursday").val();
                    currentUpdateEvent.Friday = $("#lblfriday").val();
                    currentUpdateEvent.Saturday = $("#lblsaturday").val();
                    currentUpdateEvent.Sunday = $("#lblsunday").val();

                    $('#calendar').fullCalendar('updateEvent', currentUpdateEvent);


                }

            }


        }

    });

1 个答案:

答案 0 :(得分:0)

此禁用按钮具有给定ID:

$("#"+ID).button("disable");

请将ID替换为包含按钮ID的变量