Using phpbb javascript modal dialogs

Discussion forum for Extension Writers regarding Extension Development.
Post Reply
User avatar
javiexin
Code Contributor
Posts: 1157
Joined: Wed Oct 12, 2011 11:46 pm
Location: Madrid, Spain
Name: Javier
Contact:

Using phpbb javascript modal dialogs

Post by javiexin »

Hello,

I have a question. In an extension I am working on, I want to use some modal dialogs from within javascript code. The usual: I want to get user confirmation, and when the user clicks "Confirm" then execute the code and show a "Done" message (that would autoclose in some time).

Now, I have seen the phpbb.confirm and phpbb.alert functions in core.js but unfortunately I cannot make them work as I would like to. I would like to add a JS function to a button that will call the phpbb.confirm, that shows the confirm message and captures the response, and then depending on the response, either executes the action, or cancels it. Up to there, I was able to make it work as expected using phpbb.confirm. My problem is on trying to inform the user of the "success" or "failure" of the operation (that phpbb.confirm does not do). Note that this action is NOT an Ajax call, it is just plain JS code. I have tried to call phpbb.alert at the end of the function that executes the action, after the call to phpbb.confirm, a number of combinations. But I cannot make it work properly.

My main "inspiration" has been Kasimi's "Mark forum/topics read" extension, that does almost exactly what I wanted, but using an Ajax call as action, that is the one that opens the alert dialog when done. Not my case, unfortunately.

Any help, or sample code that I can look at? Thanks a lot!!
-javiexin
Post Reply

Return to “Extension Writers Discussion”