结束行“\n”在 FBJS 对话框中

发布于 2024-09-04 18:52:25 字数 311 浏览 5 评论 0原文

我正在尝试显示带有多行消息的 FBJS 对话框。

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);

但那段代码在同一行中显示了该消息。

有人知道该怎么做吗?

谢谢。 埃内斯托·卡里翁

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

╰◇生如夏花灿烂 2024-09-11 18:52:25

当对话框中显示文本以外的内容时,您应该使用 fb:js 字符串。

这是一个例子:

<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>

然后你就有了显示对话框的函数:

<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>

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>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文