いわゆるportlet(jQuery)を含むページがあります。すべてのポートレットデータ(それらを含む列のIDを含む)を含むダイアログを開くボタンが必要です。
したがって、ダイアログを次のように表示する必要があります。
col1:
ポートレットタイトル:Title1
ポートレットコンテンツ:Title1のコンテンツ。
ポートレットタイトル:Title2
ポートレットコンテンツ:Title2のコンテンツ。
col2:
ポートレットタイトル:TIIIIITLE
ポートレットコンテンツ:TIIIIITLEのコンテンツ
ポートレットタイトル:TIIIIITLE22121
ポートレットのコンテンツ:TIIIIITLE2212のコンテンツ
またはそのようなもの。重要な部分は、ポートレットデータにアクセスする方法です。
編集:私はこのjquery(および以下のいくつかのhtml)を追加しました。これはポートレットデータとのダイアログを開きますが、それは私が望むことをしていないだけです。タイトル/コンテンツ(a / 1)と(b / 2)の2つのポートレットがあり、ダイアログを開くと、次のようになります。ab 12 ab 12.必要なもの:a 1b2.下の行は必要なものです変更するには、各ステートメントで現在のポートレットのヘッダー/コンテンツを使用します。
allContent += $(".portlet-header").text() + '\n' + $(".portlet-content").text() + '\n\n';
より多くの新しいjQuery
$( "#dialog-form-html" ).dialog({
autoOpen: false,
height: 600,
width: 400,
modal: true,
buttons: {
Cancel: function() {
$( this ).dialog( "close" );
}
},
close: function() {
}
});
$( "#get-html" )
.button()
.click(function() {
var allContent = "";
$(".portlet").each(function(){
allContent += $(".portlet-header").text() + '\n' + $(".portlet-content").text() + '\n\n';
});
$( "#dialog-form-html" ).text(allContent);
$( "#dialog-form-html" ).dialog( "open" );
});
jQueryコード:
<script type="text/javascript">
$(function() {
var title = $( "#title" ),
content = $( "#content" ), column = $( "#column" );
$( "#dialog-form" ).dialog({
autoOpen: false,
height: 300,
width: 350,
modal: true,
buttons: {
"Add content": function() {
if(column.val()=='col1'){
$( "#col1" ).append($('<div class="portlet ui-widget ui-widget-content ui-helper-clearfix ui-corner-all">' +
'<div class="portlet-header ui-widget-header ui-corner-all">' +
'<span class="ui-icon ui-icon-minusthick"></span>' + title.val() + '</div>' +
'<div class="portlet-content">' + content.val() + '</div></div>'))
$( this ).dialog( "close" );
}
else if(column.val()=='col2'){
$( "#col2" ).append($('<div class="portlet ui-widget ui-widget-content ui-helper-clearfix ui-corner-all">' +
'<div class="portlet-header ui-widget-header ui-corner-all">' +
'<span class="ui-icon ui-icon-minusthick"></span>' + title.val() + '</div>' +
'<div class="portlet-content">' + content.val() + '</div></div>'))
$( this ).dialog( "close" );
}
else if(column.val()=='col3'){
$( "#col3" ).append($('<div class="portlet ui-widget ui-widget-content ui-helper-clearfix ui-corner-all">' +
'<div class="portlet-header ui-widget-header ui-corner-all">' +
'<span class="ui-icon ui-icon-minusthick"></span>' + title.val() + '</div>' +
'<div class="portlet-content">' + content.val() + '</div></div>'))
$( this ).dialog( "close" );
}
else if(column.val()=='col4'){
$( "#col4" ).append($('<div class="portlet ui-widget ui-widget-content ui-helper-clearfix ui-corner-all">' +
'<div class="portlet-header ui-widget-header ui-corner-all">' +
'<span class="ui-icon ui-icon-minusthick"></span>' + title.val() + '</div>' +
'<div class="portlet-content">' + content.val() + '</div></div>'))
$( this ).dialog( "close" );
}
else{
$( "#tempcol" ).append($('<div class="portlet ui-widget ui-widget-content ui-helper-clearfix ui-corner-all">' +
'<div class="portlet-header ui-widget-header ui-corner-all">' +
'<span class="ui-icon ui-icon-minusthick"></span>' + title.val() + '</div>' +
'<div class="portlet-content">' + content.val() + '</div></div>'))
$( this ).dialog( "close" );
}
},
Cancel: function() {
$( this ).dialog( "close" );
}
},
close: function() {
//test();
}
});
$( "#add-content" )
.button()
.click(function() {
$( "#dialog-form" ).dialog( "open" );
});
$( ".column" ).sortable({
connectWith: ".column"
});
$( ".portlet" ).addClass( "ui-widget ui-widget-content ui-helper-clearfix ui-corner-all" )
.find( ".portlet-header" )
.addClass( "ui-widget-header ui-corner-all" )
.prepend( "<span class='ui-icon ui-icon-minusthick'></span>")
.end()
.find( ".portlet-content" );
$( ".column" ).disableSelection();
$("#centered").on('click', ".portlet-header .ui-icon", function() {
$( this ).toggleClass( "ui-icon-minusthick" ).toggleClass( "ui-icon-plusthick" );
$( this ).parents( ".portlet:first" ).find( ".portlet-content" ).toggle();
});
});
</script>
編集:新しいダイアログ用にこのhtmlも追加しました:
<div id="dialog-form-html" title="Copy html into email">
<p>
test
</p>
</div>
HTML:
<body>
<div id="centered">
<div id="inset">
<h1>HALLÅ EKONOMEN</h1>
<div id="linear" style="padding: 20px"></div>
</div>
<div id="dialog-form" title="Create new user">
<p class="validateTips">All form fields are required.</p>
<form>
<fieldset>
<label for="title">Title</label>
<input type="text" name="title" id="title" class="text ui-widget-content ui-corner-all" />
<label for="content">Content</label>
<input type="text" name="content" id="content" value="" class="text ui-widget-content ui-corner-all" />
<label for="column">Column</label>
<select name="column" id="column" class="ui-spinner-down ui-widget-content ui-corner-all">
<option value="col1">left sidebar</option>
<option value="col2">main</option>
<option value="col3">bottom left</option>
<option value="col4">bottom right</option>
</select>
</fieldset>
</form>
</div>
<button id="add-content" >Add Content</button>
<div id="preview">
<table>
<tbody>
<tr>
<!--sidebar-->
<td>
<div id="col1" class="column">
</div>
</td>
<!--sidebar end-->
<td>
<table>
<tbody>
<!--main-->
<tr>
<div id="col2" class="column">
</div>
</tr>
<!--main end-->
<!--bottom colums-->
<tr>
<td style="border-left: 0px; border-bottom: 0px">
<div id="col3" class="column">
</div>
</td>
<td style="border-right: 0px; border-bottom: 0px">
<div id="col4" class="column">
</div>
</td>
</tr>
<!--bottom colums end-->
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
Trash column:<br /><br /><br />
<div id="trashcol" class="column">
</div>
</div>
</div>
</body>