8
$("#note_content").dialog({
            title: "Note",
            modal: true,
            width:'auto',
            height:'auto',
            resizable:false,

            open: function(){
                var note_text = $('#note_content').attr('note_text');
     }
}

在我的代码中,我尝试将 note_text 设置为对话框的内容,知道我该怎么做吗?

4

2 回答 2

19

You can try this: DEMO

var SplitText = "Title"
var $dialog = $('<div></div>')
    .html(SplitText )
    .dialog({
        height: 500,
        width: 600,
        title: 'Title'});

$dialog.dialog('open');

$dialog.html('Some text');
​

​</p>

​</p>

于 2012-04-28T09:38:47.290 回答
4

You should have a content place holder inside your dialog, for example:

<div id="noteContent" title="Basic dialog">
   <p id="contentholder"> This is the default dialog which is useful for displaying information. The dialog window can be moved, resized and closed with the 'x' icon.</p>
</div>

$("#note_content").dialog({
    title: "Note",
    modal: true,
    width:'auto',
    height:'auto',
    resizable:false,

    open: function(){
        var note_text = $('#note_content').attr('note_text');
       $("#contentholder").val(note_text)
    }
}

You had your note_text assigned to a variable in this line:

var note_text = $('#note_content').attr('note_text');

However, you didn't assign the note_text variable to the placeholder.

于 2012-04-28T09:37:15.213 回答