JQuery callback functions fired before event
I don't know if I am doing some silly mistake here but facing this problem of firing callback functions on page init before actual event happens.
Here is the code
- $(document).on("pageinit",function(){
- $("#discInvitePopUp").popup({
- transition: "slidedown",
- history: false,
- afterclose: function( event, ui ) {
-
- activeDiscInviteCloseHandler();
- },
- afteropen: function( event, ui ) {
- openDiscFrmInvite();
- }
- });
-
- }
here are the callback functions:
- function activeDiscInviteCloseHandler(){
- //some code
- //curDiscInv set
- alert("evt");
- $.post("/ajaxReq/user_action.php", {
- unsetInvite:JSON.stringify(curDiscInv)
- }, function(data){
-
-
- });
-
- }
- function openDiscFrmInvite(){
- //some code
- }
here problem is that
- activeDiscInviteCloseHandler()
function is called as soon as pageinit event is triggered as a result it sends post data to server which is not desirable.
Any possible solutions to avoid this.