tc/pjax-bundle

TcPjaxBundle

安装: 116

依赖项: 0

建议者: 0

安全: 0

星标: 1

关注者: 4

分支: 0

公开问题: 0

类型:symfony-bundle

v1.0.2 2015-08-10 09:39 UTC

This package is not auto-updated.

Last update: 2024-09-28 18:42:11 UTC


README

Latest Stable Version

SensioLabsInsight

整合Pjax到Symfony

安装

composer require tc/pjax-bundle

在您的 AppKernel.php 中启用该包

$bundles = array(
    // ...
    
    new Tc\Bundle\Pjax\TcPjaxBundle(),
    
    // ...
);

将脚本包含在您的模板中

<script src="{{ asset('bundles/tcpjax/vendor/jquery.js') }}"></script>
<script src="{{ asset('bundles/tcpjax/vendor/jquery.pjax.js') }}"></script>
<script src="{{ asset('bundles/tcpjax/js/tc-pjax.js') }}"></script>

{# OR #}

{% javascripts
 '@TcPjaxBundle/Resources/public/vendor/jquery.js'
 '@TcPjaxBundle/Resources/public/vendor/jquery.pjax.js'
 '@TcPjaxBundle/Resources/public/js/tc-pjax.js'
%}
<script src="{{ asset_url }}"></script>
{% endjavascripts %}

用法

现在,您需要创建一个pjax容器,并为 fullpjax 创建不同的布局

base.html.twig

<!DOCTYPE html>
<html lang="en">
<head>
  <meta http-equiv="X-UA-Compatible" content="IE=edge"/>
  <meta charset="utf-8">
  <title>{% block title %}{% endblock %}</title>
</head>
<body>
{% block body %}{% endblock %}
<script src="{{ asset('bundles/tcpjax/vendor/jquery.js') }}"></script>
<script src="{{ asset('bundles/tcpjax/vendor/jquery.pjax.js') }}"></script>
<script src="{{ asset('bundles/tcpjax/js/tc-pjax.js') }}"></script>
</body>
</html>

base-pjax.html.twig

<title>{% block title %}{% endblock %}</title>
{% block body_inner %}{% endblock %}

your-layout.html.twig

{% extends pjax('#your-layout', '::base.html.twig', '::base-pjax.html.twig') %}

{% block title %}Your Title{% endblock %}

{% block body %}

	<div {{ pjaxContainer('#your-layout', app.debug) }}>

    {% block body_inner %}

      <h1>Your Content</h1>

    {% endblock %}

	</div>

{% endblock %}

许可协议

TcPjaxBundle 使用 MIT 许可协议。

有关详细信息,请参阅 LICENSE。