打开文本框只是第一次api调用,第二次文本框没有打开

时间:2016-06-15 14:47:45

标签: javascript jquery html angularjs

我有一个问题& aanswer模块,点击写一个问题的答案,第一次打开答案框,提交答案后,当我再次打开答案文本框时,它不会打开。

我的HTML代码

<li class="question answered" id="unansweredBlock" ng-if="unanswered_Que.length !==0">
<div class="qstn" id="qBlock-{{questions.question_id}}" ng-repeat="questions in unanswered_Que">
    <span class="qstn-icon qicon"></span>
    <div>
        <div class="qmeta">
            <div>Asked by <a href="">{{questions.asked_by}}</a> on {{questions.asked_at}}</div>
        </div>
        <h4>{{questions.question}}</h4>
    </div>
    <div id="ansId-{{questions.question_id}}" class="qbottom">
        <a href="javascript:void(0);" ng-click="showHideAnswerPanel($index)" ng- class="">Write your answer</a>
    </div>
    <hr class="seperator">
    <div class="sendAnswer" ng-show="selectedAnswerPanel== $index" ng-hide="selectedAnswerPanel != $index">
        <div class="sndAnswer">
            <form action="">
                <div class="form-group">
                    <h5>EXPERTS ANSWER</h5>
                    <textarea id="answer_Text{{$index}}" ng-model="answerText" placeholder="Write your comments" class="form-control"></textarea>
                </div>
                <div class="form-group">
                    <button type="submit" class="btn btn-default" ng-click="answer_Que(questions,'answer_Text'+$index);">Send your Answer</button>
                </div>
            </form>
        </div>
    </div>
</div>

我的JS代码

$scope.showHideAnswerPanel = function(index) {
if ($rootScope.isUserLoggedIn == true) {
    if ($scope.selectedAnswerPanel == index) {
        $scope.selectedAnswerPanel = -1
    } else {
        $scope.selectedAnswerPanel = index;
    }
} else {
    $rootScope.openLogin();
}

};

另一个功能是: -

$scope.answer_Que = function(unanswered_Que, answerExp) {
var requestParam = {
    "uid": lclStorage.get('userData')[0].uid,
    "token_key": lclStorage.get('userData')[0].token_key,
    "question_id": unanswered_Que.question_id,
    "answer": $("#" + answerExp).val()
}
appServices.doAPIRequest(appSettings.appAPI_ci.answeraQue.sendAnswer, requestParam, null, 'userData')
    .then(function(data) {

    });
if ($scope.unanswered_Que.length == 1) {
    $("#answer_Text").val(" ");
    $(".sendAnswer").hide();
    $("#unansweredBlock").remove();
} else if ($scope.unanswered_Que.length > 1) {
    $("#answer_Text").val(" ");
    $(".sendAnswer").hide();
    $("#qBlock-" + unanswered_Que.question_id).remove();
} else {
    $("#answer_Text").val(" ");
    $(".sendAnswer").hide();
}

};

0 个答案:

没有答案