I am currently facing an issue while trying to access a specific function within a SignalR connection function. Below is the code snippet showcasing the entire script for better understanding:
$(function() {
var chat = $.connection.chatHub;
chat.client.informOfStatusRequest = function(personToNotify, message) {
var sysUserId = @Convert.ToInt32(HttpContext.Current.Request.Cookies["sys_user_id"].Value);
if (sysUserId === personToNotify) {
$.notify({
icon: 'glyphicon glyphicon-star',
message: message
}, {
animate: {
enter: 'animated fadeInRight',
exit: 'animated fadeOutRight'
}
});
}
}
$.connection.hub.start().done(function() {
function disapproveTicket(ticketId, createdById) {
bootbox.confirm({
title: 'CONFIRM',
message: 'Disapprove ticket ID ' +ticketId +'?',
buttons: {
confirm: {
label: 'YES',
className: 'btn-success'
},
cancel: {
label: 'NO',
className: 'btn-danger'
}
},
callback: function(response) {
if (response === true) {
$.ajax({
type: 'POST',
url: '/Member/DisapprovePendingTicket',
data: {ticketId: ticketId} ,
success: function(result) {
if (result === true) {
$.notify({
icon: 'glyphicon glyphicon-star',
message: "Ticket has been disaproved"
}, {
animate: {
enter: 'animated bounceIn',
exit: 'animated bounceOut'
}
}, {
type: 'success'
});
$("#div_get_pending_ticket").load('/Member/GetPendingTicket');
getPendingRequestCount();
chat.server.informUserOnRequestStatus(createdById,"Ticket has been disaproved");
} else {
$.notify({
icon: 'glyphicon glyphicon-star',
message: "Failed in disapproving the ticket."
}, {
animate: {
enter: 'animated bounceIn',
exit: 'animated bounceOut'
}
}, {
type: 'success'
});
}
}
});
}
}
});
}
});
});
When attempting to call the "disapproveTicket" function, I encountered an error stating that it is undefined. The function "disapproveTicket" resides within a $(function()) and is encompassed by $.connection.hub.start().done(). Despite browsing through other responses on accessing nested functions, I have not been successful due to differences in structure. Could you kindly provide guidance on how to resolve this issue? Thank you.