javascript - Unable to reach a function inside SignalR connection function -
i trying access function inside signalr connection function. better illustrate code whole script.
$(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 ticket." }, { animate: { enter: 'animated bouncein', exit: 'animated bounceout' } }, { type: 'success' }); } } }); } } }); } }); });
and how try access "disapproveticket" function:
<td> <a href="javascript:void(0);" onclick="">check</a> | <a href="javascript:void(0);" onclick="disapproveticket(@item.ticketid, @item.createdbyid)">disapprove</a> </td>
on console says "disapproveticket undefined". disapproveticket inside $(function()) , inside $.connection.hub.start().done(). i've seen other answers on how access nested functions structure different have. can please show me? thank you.
i saw function disapproveticket() can use when $.connection.hub.start().done(). onclick attribute in html element can't call it. think must use
$.connection.hub.start().done(function(){ $("#your_element").click(function(){ disapproveticket() }) })
hope can you
Comments
Post a Comment