Giter VIP home page Giter VIP logo

yii2-intercooler's Introduction

Yii2 Intercooler integration

Easy integration of Intercooler.js (the easy to use Ajax handler) into Yii2 framework. Provides bunch of ready to use widgets with preddefined Intercooler requirements.

See Intercooler.js official docs on http://intercoolerjs.org

Installation

The preferred way to install this extension is through composer.

Either run

$ composer require dlds/yii2-intercooler

or add

"dlds/yii2-intercooler": "~2.0"

to the require section of your composer.json file.

Module Base Class

Base module class Intercooler holds all options for Intercooler required html element attributes. Also handles registering of required js files using IntercoolerAssets. It is usually init through some of included widgets.

Response Headers

Using base class static methods you are allowed to set specific intercooler headers.

X-IC-Redirect

To be able to redirect user to new url after intercooler request is done you have to set redirect header in server side.

Intercooler::doRedirect('/new-destination-url');

X-IC-Refresh

To refresh intercooler elements you can set refresh header on your server side and tell intercooler which elements should be refreshed.

Intercooler::doRefresh([
	'/foo/bar'
]);

See what '/foo/bar' stand for in official docs

X-IC-Remove

To remove targetted element you have to set remove header on server side.

Intercooler::doRemove();

Widgets

Integration comes with buch of ready made modules based on intercooler behavior.

AjaxBlock

Helper which renders appropriate html element with required intercooler attributes.

AjaxBlock::begin([
	'id' => 'my-ic-widget',
	'wrapper' => 'button',
	'options' => ['class' => 'text-gray']
	'intercooler' => [
		'url' => '/my-custom-url',
		'target' => '#my-target-element',
	],
]);

// ... custom content

AjaxBlock::end();

For more widget options see AjaxBlock class documentation.

InfiniteList

Renderes Infinite ListView widget.

InfiniteList::widget([
	'id' => 'my-ic-infinite-list,
	// 	...
	//	standart ListView widget options
	// 	...
	'layout' => "{indicatorRefresh}<div class=\"items\">{items}{pager}</div>\n",
	'partialLayout' => "{items}{pager}\n",
	'intercooler' => [
		'url' => '/my-ic-feed-url,
		'type' => \dlds\intercooler\Intercooler::RQ_TYPE_SRC,
	],
	'pager' => [
    	'class' => InfiniteListPager::className(),
    ],
]);

For more widget options see InfiniteList class documentation.

yii2-intercooler's People

Contributors

jirisvoboda avatar svobik7 avatar

Stargazers

 avatar Tobias Munk avatar Philipp Frenzel avatar

Watchers

James Cloos avatar Philipp Frenzel avatar  avatar

yii2-intercooler's Issues

Error Installing via composer

i tried to install yii2-intercooler 2.2 and facing with this error
dlds/yii2-intercooler 2.2 requires bower-asset/intercooler-js ~0.9.4 -> no matching package found
i have added bower-asset/intercooler-js ~0.9.4 in composer.json require. It seem the intercooler asset already removed.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.