0

これは私が考えすぎた単純な問題かもしれませんが、何をする必要があるのか​​ わかりません。

<div class="commentsMain">
      ... Contents loaded with ajax ...
</div>

<script type="text/javascript">
$(document).ready(function() {
    var maxPage = @Model.NumberOfPages;
    var nextPage = @Model.CurrentPage + 1;

    // Loads new comments and adds them to the comments main div
    $("#loadNextComments").live("click",function() {
        if (nextPage <= maxPage) {
            $("#loadNextCommentsDiv").remove();
            loadNewComments('@Url.Action("Comments", "Comments")', nextPage, @Model.CommentItemId, @Model.CommentItemType );
            nextPage++;
        }
    });
     // This function submits the comment and then the nextPage variable
     // is supposed to be set back to @Model.CurrentPage + 1
     $('#commentSubmitButton').on("click",submitComment(@Model.CommentItemId, @Model.CommentItemType, addAction, nextPage));
});
</script>

commentSubmitButton をクリックした後、nextPage 変数にモデルの適切な値を再割り当てする必要があります。どうすればこれを達成できますか?ajaxの「成功」関数でこれを行うことができましたが、関数は外部ファイルにあり、そこから変数を何らかの方法で再割り当てできるかどうかわかりません。

助けてくれてありがとう。

4

1 に答える 1

1

var前の - キーワードnextPageを削除しmaxPage、変数をグローバルにします

于 2012-08-06T10:40:47.793 に答える