infinityloop-dev/lazy-component 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

infinityloop-dev/lazy-component

Composer 安装命令:

composer require infinityloop-dev/lazy-component

包简介

Component for Nette framwork which helps with creation of lazy ajax loaded components.

README 文档

README

🔧 Component for Nette framwork which helps with creation of lazy ajax loaded components.

Introduction

Component which renders empty in the beggining and is populated by signal request.

Installation

Install package using composer

composer require infinityloop-dev/lazy-component

Dependencies

How to use

  • Create new component and extend \Infinityloop\LazyComponent\LazyComponent instead of \Nette\Application\UI\Control.
  • Trigger handleLoadComponent to load and redraw component.
  • Use macro {control componentName} to render your component as you would normally.
  • Additionaly use {control componentName:loadComponentLink} to get URL for loadComponent signal.
    • Useful for rendering URL (eg. into data attributes) so you can easily trigger signal from javascript.
  • Make sure LazyCompoennt::render() method is called if you choose to override it.
    • Preferably use beforeRender() to pass variables into template.
    • beforeRender() method is not called when empty template is used (when component is not loaded).
  • Template for your component is automaticaly deduced to be have same name (and path) as your .php file.
    • File extension is simply swapped to .latte.
  • By default the FontAwesome 5 spinner is used as placeholder. Override EMPTY_TEMPLATE constant to use different empty template file.

Example lazy tab content

Tab header:

<li class"tab" data-load-component="{control myComponent:loadComponentLink}">Tab name</li>

Tab content:

<div class="tab-content">
    {control myComponent}
</div>

JQuery ajax request on click:

$(".tab[data-load-component]").one('click',function (event) {
    const link = $(this).data("load-component");
    $.nette.ajax({
        method: 'GET',
        url: link,
    });
});
  • Load event is executed only once (jqery.one).

统计信息

  • 总下载量: 567
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 4
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 4
  • Watchers: 2
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-01-19

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固