非常にうまく機能し、使いやすいプロジェクトで WYMeditor を使用しています。画像のサムネイルを含むモーダルを開くカスタム ボタンを追加しました。画像をクリックすると、WYMeditor に挿入されます。問題は、クリックされた最初の画像は素晴らしいですが、複数の画像を挿入しようとすると、「倍増」します。つまり、最初の画像クリック = 1 つの画像挿入、2 回目の画像クリック = 2 つの画像挿入、3 回目のクリック = 3 つの画像挿入などです。の上。また"</span>"
、画像の挿入後に、これはまったく必要ありません。なぜこれが起こっているのか、手がかりがわかりません。WYM インサートのコードは次のとおりです。
jQuery('.wymeditor').wymeditor({
html: '<p>Hello, World!<\/p>',
postInit: function(wym) {
var html = "<li class='wym_tools_newbutton'>"
+ "<a name='NewButton' href='#'"
+ " style='background-image:"
+ " url(includes/js/wymeditor/img/media.png);'"
+ " title='Insert an image' >"
+ "</a></li>";
jQuery(wym._box).find(wym._options.toolsSelector + wym._options.toolsListSelector).append(html);
jQuery(wym._box).find('li.wym_tools_newbutton a').click(function() {
jQuery('#modal').show().css( { 'left': (winW-980)/2+'px', 'top': '100px' } ).load('includes/admin/adminListMedia.php');
jQuery('.imgname').live('change',function(){
var InsertImg = '#'+jQuery(this).attr('id');
wym.insert('<img src="http://127.0.1/admin/includes/uploads/'+jQuery(InsertImg).val()+'" />');
jQuery('#modal').empty().hide();
});
return(false);
});
ご覧のとおり、挿入時にモーダルを閉じて空にしましたが、重複を「クリア」しようとしてこれを行いましたが、機能せず、これが「モーダル」コードです。
<?php
if ($handle = opendir('../../includes/uploads/thumb/')) {
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != "..") { ?>
<div class="MediaImgSelect wym_src">';
<img src="includes/uploads/thumb/<?php echo $file; ?>" width="90px" height="90px"/>';
Size
<select class="imgname" id="<?php echo 'img_'.substr($file,0,-4); ?>">
<option value="Select">Select</option>
<option value="thumb/<?php echo $file; ?>">Thumb</option>
<option value="thumb/<?php echo $file; ?>">Small</option>
<option value="thumb/<?php echo $file; ?>">Large<option>
</select>
</div>
<?php }
}
closedir($handle);
}
?>