OK, so I am trying to make a few "Are You Sure" fancyBox. Well really one, but used in a few cases which each case a little bit different. I found some cool code and I just can't seem to get it to work. I get the popup, but when I click OK or Cancel buttons I added, their click functions aren't getting called at all, and the page refreshes. Here is my code.
This gets fired when one of the delete buttons in a list of items gets clicked for that particular item. I have this dataObject because in a list of guests the data that the confirmed function needs is different.
here is my fancyConfirm function, which pops up the fancybox, but the clicks aren't working.
Here is the template "areYouSure"
var makeSureText = ich['areYouSure'](dataObject);
is a String holding the generated html from the template. Now with a nice specific message.
If you are going to say I can't pass the dataObject, I will also say that I had a version where the dataObject wasn't being passed in and had the same issue that the function in onComplete never gets called.
Joined: Nov 08, 2001
What your code is saying is that the onclick event is passing in an argument into the function.
Solution is delete the variable from the the arguments of the click!
Yeah, doing a bit more testing, nothing inside the onComplete or onClosed is getting called.
And now that part is solved I have onComplete being called, or should I say afterLoad. onComplete is in version 1.3 of fancyBox, but not in 2.x, which is what I am using. That's what you get when you Google and copy code from someone else. ;)
It still isn't 100% working, but I got a bit further. Now to figure out how to get that callback function in dataObject to get called. I am still getting the entire page refreshed, which in my case means they lose wha tthey were looking at and go back to the main page.
OK getting even more closer. The buttons on the confirm dialog in fancybox click code is running. But now I callback to my dataObject's confirm function, and that is getting called, but not working correctly. It seems to be called twice. And it doesn't have access to my eventId in my dataObject.
Here is the code I am at now.
And final fancyConfirm function
Yeah, I decided to forget about afterLoad. I would have only needed that if I made the fancyBox be modal, but it really doesn't have to be modal. If they click the X or outside the fancyBox that means the same as clicking cancel, in which I just dismiss/close the fancyBox anyway.
Thanks, so right now this is running twice and the eventId is not known
OK, I think this should be the last problem. I think.
See in my call to .post() I am trying to get the eventId that I passed in as data. Of the 4 vars, only one shows data (andYet) and it is not what I would expect. And I don't think I want to do String parsing just to get my id. But andYet is set to "eventId=309". I only want the 309 part. How do I get that? I tried different ways as you see in the other variables, but I can't find a combination that works.
OK finally resolved. Everything is working. Had to change the way I got my eventId in the .post method again.
I also forgot that this function gets called when the event owner deletes items needed for the event as well as for guests that signed up to bring that item, can unsign themselves up. And so each would need a different message. Which I could push the message string up to those calls. Which I think I will now that I am talking about it. Hate having if statements like that.
And the Confirm function is still the same as my last post of it.
Thanks Eric for your help.
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
subject: Confirm FancyBox, buttons not calling click functions.