Skip to content
Durisvk edited this page Dec 18, 2016 · 1 revision

Groups

Now that we understand the Intervals Database and Registry we can move on some easier stuff. Let's learn about Groups.

Let's create our view with three buttons added to one group using data-group attribute. We want to show the clicked button's value inside div.

app/view/indexView.php:

<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
</head>
<body>

	<div id="lblView"></div>
	<input type="button" data-group="buttons" value="1" />
	<input type="button" data-group="buttons" value="2" />
	<input type="button" data-group="buttons" value="3" />

</body>
</html>

Now we can create our controller.

app/controller/indexEOSS.php:

<?php

use EOSS\EOSS;

class indexEOSS extends EOSS
{

    public function load()
    {
        $this->csi->setFile("indexView.latte.php");
    }

    public function bind()
    {

        $this->csi->buttons->onclick[] = "showNumber";
    }


    public function showNumber($sender) {
        $this->csi->lblButtons->html = $sender->value;
        $sender->value += 1;
    }

}

Now we can use the group we've defined earlier to bind the event to the all elements in that group. You can but don't have to specify the id attribute to the elements of the group.

To make it clear, groups are commonly used when you load some data from database, let's more rows than one and you want to print them out and have some common actions upon them, then you use data-group attribute inside their tag and you can bind a common event such as for example like/dislike on a forum posts, delete person from persons list, ... and so on

And we are done...

We are looking for contributors, come and join us, write me an email on durisvk2@gmail.com or post something on a http://eoss.wz.sk .

Clone this wiki locally