私のバックボーン アプリケーションでは、検索結果ページに #show アクションへのリンクがあります。この表示アクションは、指定されたモデルを表示します。
-検索結果のURI
/search
-指定されたモデル URI
/:modelName/:viewName/:id
(ご覧のとおり、modelName と viewName もパラメーターとして Router アクションに渡します)
ユーザーが表示ページにいる場合、検索結果に戻るオプションが必要です (例: [検索結果に戻る] ボタン)。検索結果にはページネーションがあるため、何度も取得するのは賢明ではありません。また、レコードを取得するとcollection
状態が失われます。
検索結果をメモしたい。
これが検索のコードです(Backbone.Router
アクション)
search: (query) =>
sentencesCollection = new SI.Collections.Sentences()
searchParamSets = new SI.Collections.SearchParamSets()
sentencesView = new SI.Views.SentencesSearchForm(
collection: sentencesCollection
searchParamSets: searchParamSets
)
resultsView = new SI.Views.SearchResults(
collection: sentencesCollection
searchParamSets: searchParamSets
viewName: "SentencesShow"
)
@searchView.show(sentencesView)
@contentView.show(resultsView)
@sidebarView.show(new SI.Views.SentencesSearchFilters(
searchParamSets: searchParamSets
))
new SI.Views.SearchParamSets(collection: searchParamSets)
if query?
searchParamSets.reset({name: query})
sentencesView.appendSearchSetAndGetSentences()
ユーザーが「戻る」ボタンをクリックすると、search
アクションRouter
がトリガーされます。同じオブジェクトを再作成せずに使用したい。したがって、基本的にこのコードはリファクタリングが必要になります。
私の質問:
検索結果を記憶するには?