Skip to content

Commit db7d68a

Browse files
author
hikki
committed
7
1 parent e98a9bc commit db7d68a

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

src/Layer/Dialog.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,23 @@ public function __construct(array $xhr = ['url' => '', 'method' => 'POST'])
1515
$this->xhr = json_encode(array_merge($this->xhr, $xhr));
1616
}
1717

18+
/**
19+
* @param $selector
20+
* @param string $event
21+
* @return $this
22+
*/
23+
public function trigger($selector, $event = 'click')
24+
{
25+
$this->trigger = <<<EOF
26+
if(document.querySelector('$selector')){
27+
document.querySelector('$selector').addEventListener('$event', function () {
28+
%s
29+
});
30+
}
31+
EOF;
32+
return $this;
33+
}
34+
1835
/**
1936
* @param array $options
2037
*/

0 commit comments

Comments
 (0)