tags:

views:

89

answers:

1

Hi,

I'm trying to show a FBJS Dialog with a multiline message.

message += "Please enter the name of the Post.\n"
message += "Please enter content.\n"
message += "Content must have at least 10 characters.";

new Dialog().showMessage("Error", message);

But that piece of code shows the message in the same line.

Does anybody knows how to do that?

Thanks. Ernesto Carrión

+1  A: 

You should use an fb:js-string when you have something other than text to show in a dialog.

Here's an example:

<fb:js-string var="messageToShow">
  Here's some text.<br />
  and some more text...<br />
  <p>You can even have HTML or FBML tags in here!</p>
  <img src="http://absolute.path.to/the/image.jpg" />
  <form id="selectFriendForm">
    <label class="RedLabel">Select a friend:</label>
    <fb:friend-selector name="uid" idname="selected_friend" />
  </form>
</fb:js-string>

And then you have the function that shows the dialog:

<script type="text/javascript">
  function showDialog() {
    var dialog = new Dialog(Dialog.DIALOG_POP);
        dialog.showChoice('Select a friend',
        messageToShow, // fb:js-string var name
        button_confirm = 'Choose this friend',
        button_cancel = 'Cancel'
      );

    dialog.onconfirm = function() {
      var formData = document.getElementById('selectFriendForm').serialize();
      // ajax call to save my selected friend or whatever
    }
  }
</script>
agbb
The thing is that i don't know what the message should contain, so I need to build the message in execution time, and I that's what i don't know how is done.
Ecarrion
just put a <div id="variableMessageContent"></div> inside the <fb:js-string> tag, and then you dynamically put the content you need using document.getElementById('variableMessageContent').setInnerFBML("my dynamic message"); on execution time
agbb

related questions