我正在尝试使用多行消息显示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);
但是那段代码在同一行显示了消息。
有人知道该怎么做吗?
感谢。 埃内斯托·卡里翁
答案 0 :(得分:1)
当你在对话框中显示除文本之外的其他内容时,你应该使用fb:js-string。
以下是一个例子:
<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>