-
Notifications
You must be signed in to change notification settings - Fork 0
Events
Durisvk edited this page Dec 19, 2016
·
2 revisions
Let's create a textbox
which content will be copied into a div
element real-time.
First we will need a view. Let's create a rewrite.php
file.
app/view/rewrite/rewrite.php
:
<!DOCTYPE html>
<html>
<head>
<title><?= $title ?></title>
</head>
<body>
<div id="lblCopy"></div>
<input type="text" id="txtSource">
<input type="button" id="back" value="Back" />
<input type="button" id="next" value="Next" />
</body>
</html>
We will pass the $title
parameter into the view from our EOSS controller. Let's now create indexEOSS
class.
app/controller/indexEOSS.php
:
<?php
use \EOSS\EOSS;
class indexEOSS extends EOSS
{
public function load()
{
$this->csi->setFile("rewrite/rewrite.php");
}
public function bind()
{
$this->csi->txtSource->onkeypress[] = "rewrite";
}
public function rewrite($sender, $keyCode) {
$this->csi->lblCopy->html = $this->csi->txtSource->value;
}
}
And we're done. That's it.
We could also do inline event binding like this:
<div id="lblCopy"></div>
<input type="text" data-event="Event: 'onkeypress', Action: 'rewrite'">
And so we don't need to specify the id
.
Available events(some will be added over time):
{
"onclick": "click",
"onhover": "hover",
"onchange": "change",
"onfocus": "focus",
"onfocusin": "focusin",
"onfocusout": "focusout",
"onload": "load",
"onmousedown": "mousedown",
"onkeypress": "keypress:keyCode",
"onenterpressed": "keypress-event.keyCode==13"
}
Welcome to EOSS, we are glad to see you here.
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 .