我試圖把字符留在textarea中。但它無法工作。我的腳本:TinyMCE字符剩餘
<script type="text/javascript">
function updateCountdown() {
// 140 is the max message length
var remaining = 300 - jQuery('.short').val().length;
jQuery('.countdown').text(remaining + ' characters remaining.');
}
jQuery(document).ready(function($) {
updateCountdown();
$('.short').change(updateCountdown);
$('.short').keyup(updateCountdown);
});
</script>
<label>Short message <span class="countdown"></span></label>
<?php echo form_textarea('short_content', '', 'class="short"'); ?>
我使用了tinymce編輯器。它只在我重新播放頁面時起作用。誰能幫忙?
我add.php文件看起來像這樣:
<script type="text/javascript">
function updateCountdown(remaining_text) {
// 140 is the max message length
var remaining = 300 - remaining_text.length;
jQuery('.countdown').text(remaining + ' characters remaining.');
}
</script>
<label>short content <span class="countdown"></span></label>
<?php echo form_textarea('short_content', '', 'class="short"'); ?>
我的TinyMCE的初始化文件看起來像這樣:
var short = $('textarea.short');
if(short.length > 0) {
short.tinymce({
height: 150,
language : 'lt',
script_url : 'js/tiny_mce/tiny_mce.js',
theme : 'advanced',
skin : 'wp_theme',
theme_advanced_toolbar_location : 'top',
theme_advanced_toolbar_align : 'left',
theme_advanced_resizing : true,
plugins : "maxchars,autolink,lists,pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template,advlist,wordcount",
theme_advanced_buttons1 : "bold,italic,underline,strikethrough,|,link,unlink,anchor,|,bullist,numlist",
theme_advanced_buttons2 : "",
theme_advanced_buttons3 : "",
theme_advanced_statusbar_location : "bottom",
max_chars : 250,
max_chars_indicator : "lengthBox",
toolbar: "wordcount",
force_br_newlines : true,
force_p_newlines : false,
forced_root_block : false,
file_browser_callback : "tinyBrowser",
setup: function(ed){
ed.onInit.add(function(ed) {
ed.pasteAsPlainText = true;
});
ed.onPaste.add(function(ed) {
ed.pasteAsPlainText = true;
});
},
});
}
});
[您的代碼似乎工作](http://jsfiddle.net/andyuws/YwLvJ/)。還有其他一些事情正在發生。 – Andy
是的,我知道它,但它只是當我reloud頁面時工作。也許這是關於以下幾點的問題:重點? – killah