"취소"버튼을 클릭 할 때 주석 상자를 닫고 주석 상자에 0 개의 기호가 있으면 게시를 허용하지 않습니다.양식을 추가 할 때 JS가 작동을 멈춘다
$(function() {
$('.panel-google-plus > .panel-footer > .input-placeholder, .panel-google-plus > .panel-google-plus-comment > .panel-google-plus-textarea > button[type="reset"]').on('click', function(event) {
var $panel = $(this).closest('.panel-google-plus');
$comment = $panel.find('.panel-google-plus-comment');
$comment.find('.btn:first-child').addClass('disabled');
$comment.find('textarea').val('');
$panel.toggleClass('panel-google-plus-show-comment');
if ($panel.hasClass('panel-google-plus-show-comment')) {
$comment.find('textarea').focus();
}
});
$('.panel-google-plus-comment > .panel-google-plus-textarea > textarea').on('keyup', function(event) {
var $comment = $(this).closest('.panel-google-plus-comment');
$comment.find('button[type="submit"]').addClass('disabled');
if ($(this).val().length >= 1) {
$comment.find('button[type="submit"]').removeClass('disabled');
}
});
});
을 내가 HTML의 FORM을 추가 할 때 :이 코드는 잘 작동
<form method="POST" action="/komentuoti/{{$p->id}}">
{!! csrf_field() !!}
<div class="panel-google-plus-textarea form-group">
<textarea rows="2" cols="60" class="form-control" name="body" placeholder="Rašykite komentarą"></textarea>
<br>
<button type="submit" class="btn btn-success disabled">Post</button>
<button type="reset" class="btn btn-default">Cancel</button>
<hr>
<strong><h5>Komentarai</h5></strong>
@foreach($p->comment as $com)
<ul class="list-unstyled">
<li><strong>{{$com->user->name}}</strong> {{$com->body}}</li>
</ul>
@endforeach
</div>
<div class="clearfix"></div>
</form>
JS 나던 작업을 더 이상 주석 상자를 닫습니다하지 않습니다. 이 문제를 해결하는 방법? 그것없이 잘 작동합니다 <form></form>
코드가 "작동하지 않는 방법"에 대해 자세히 설명해 주시겠습니까? 당신은 무엇을 기대하고 있었고 실제로 무슨 일이 일어 났습니까? 예외/오류가있는 경우 발생한 행을 게시하고 예외/오류 세부 정보를 게시하십시오. 이 세부 정보를 입력하거나 편집하지 않으면 도움이되지 않을 수 있습니다. –
코드 주위에 양식 태그를 추가하면 JS 코드가 기능을 수행하지 않습니다. –
예외가 발생합니까? 그렇다면 예외는 무엇입니까? 아마도 여기가 핵심 부분 일 것입니다. –