Creating a loading message message in a Facebook dialog is not as straightforward as it could be. I admit, this is one area where Facebook could stand to improve its JavaScript and Markup Language implementations. After spending a few hours trying to come up with a method to do this, I finally came up with the following setup.
First, I need to pass loading message FBML to the FBJS Dialog constructor. Second, I need to make the AJAX request for the desired dialog contents. Finally, I need to replace the loading FBML with that returned in the AJAX response.
The Loading Message
In order to pass FBML (or even pure HTML) into an FBJS Dialog, it must be pre-rendered. This adds a slight complication to the solution. Fortunately, Facebook offers a means for working around this issue via the
Loading...
The extra DIV element with ID “add_dialog” is important, as we’ll see momentarily.
The FBJS
The next step is to update the FBJS function that creates the Dialog object. Previously, the AJAX call was made prior to any Dialog code executing. For this change, the Dialog needs to be created with the loading message content prior to executing the AJAX request.
Note the use of the “add_dialog_fbml” variable (as declared through the
0 komentar:
Posting Komentar