开发者

Get value from a function that was added to click event

T开发者_高级运维his is a code in document ready

 $(document).ready(function {

 $('button[id$="btnSave"]').click(function() {
        saveEvent();
    });

    function saveEvent() {
        $.colorbox.close();
        result = { date: $('#txtDate').val(), description: $('#txtDescription').val() }
        return result;
    }
});

Here is where I need this results

 var calendar = $('#calendar').fullCalendar({
    editable: true,
    disableResizing: true,
    loading: function(bool) {
        if (bool) {
            $('#loading').show();
        }
        else {
            $('#loading').hide();
        }
    },
    dayClick: function(date, allDay, jsEvent, view) {


        displayInput($(this), date);// show modal

   //!!return results from modal on mouse click!!

    },
    events: {
        url: 'UserCalendarService.asmx/GetEvents',
        type: 'POST',
        dataType: 'json',            
        contentType: "application/json; charset=utf-8"
    }
});

This works fine, but how can I get this result object in other function when I click on the Save button. For example, When Colorbox modal is showed, user click on the save button. How can I get return value of saveEvent function at that time?

Later on I'll need a callback to put this user values in calendar ui


It seems simple - see comment below.

 $(document).ready(function {

 $('button[id$="btnSave"]').click(function() {
        var returnValue=saveEvent();
        //SEND return value anywhere you want.
    });

    function saveEvent() {
        $.colorbox.close();
        result = { date: $('#txtDate').val(), description: $('#txtDescription').val() }
        return result;
    }
});
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜