入力の長さに応じてフォーム送信ボタンを無効にする基本機能を実行します。
私はこれを使用しています:
// check if the newpost text area in empty on page load and also input change
$(document).ready(function(){
disableNewPost();
$('#newpost').keyup(disableNewPost);
});
// disable new post submit button if the new post ckeditor is empty
function disableNewPost() {
if ($('#newpost').val().length > 0) {
$(".addnewpostbtn").prop("disabled", false);
} else {
$(".addnewpostbtn").prop("disabled", true);
}
}
これは、通常のテキスト領域で機能します: http://jsfiddle.net/QA22X/
しかし、CKEditor を使用する場合は機能しません。
私は自分の研究をしましたが、うまくいくものを見つけることができません。
私はこれを見て試しました:
// check if the newpost text area in empty on page load and also input change
$(document).ready(function(){
disableNewPost();
var e = CKEditor.instances['#newpost']
e.on( 'keyup', function( event ) {
disableNewPost();
});
});
// disable new post submit button if the new post ckeditor is empty
function disableNewPost() {
var value = CKEDITOR.instances['#newpost'].getData();
if ($(value).length > 0) {
$(".addnewpostbtn").prop("disabled", false);
} else {
$(".addnewpostbtn").prop("disabled", true);
}
}
しかし、それもうまくいきません。
これについて何か助けはありますか?