3

I'm using Zend Paginator here, in an ajax request I am retrieving objects based upon search results and rendering the HTML and passing it along with a rendered Zend Paginator view.

The problem is that the returning paginator doesn't take into account the new url. for example if I were to do it without ajax I would have my page url read:

www.mysite.com/?search=something&page=2

However from and ajax query it doesn't work that way the search variable is not appended to the url in the paginator links. Help please.

4

2 に答える 2

0

コードが表示されない場合はわかりませんが、Paginator Controlsのビュースクリプト(つまり、.phtmlNext、Previousなどのリンクをレンダリングするファイル)が使用して$this->url()いるようですが、検索を検出して追加するように構成されていませんリンクの最後にパラメータを設定します。

<a>コントロールビュースクリプトがそのPaginatorに固有である場合は、タグのhrefパラメータに「?search=something」を手動で追加してみてください。これにより、これらが出力に含まれるようになります。

コントローラーとビューから、Paginatorの実装方法とページのレンダリング方法を示すコードを提供していただければ幸いです。または、ライブデモは常に良いです:D

于 2011-04-20T07:04:44.083 に答える
0

pagination.phtmlファイル内で生成されたさまざまなページを指す、サイトのどこかにページネーション リンクがあると思います。

OnClick では、そのhref 属性を取得し、次のようにコンテンツをロードする必要があります。

function getContents() {
    var url = window.location.protocol + "//" + 
              window.location.host + $(this).attr('href');

    var jqxhr = $.post(url, {
        "format" : "json"
    }, function(data) {
        displayContents(data);
    }, 'html');
    return false;
} 

$(document).ready(function() {
    $("#paginator a").each(function() {
        $(this).click(getContents);
    });
});

このようにして、クラシックURLを取得します

www.mysite.com/?search=something&page=2

url フィールドを変更する必要があるかもしれません。URL フィールドに警告を表示し、変更が必要なものを確認してください。

これに関するチュートリアルは次のとおりです(検索なし):Zend Framework 1.9チュートリアル14:ajaxリクエストパート1

于 2011-04-12T09:42:29.170 に答える