Skip to content

Commit d95bac8

Browse files
committed
improve adding custom action to buttons
1 parent 6b1bac3 commit d95bac8

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

src/Html/Button.php

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,9 @@ public function exportOptions($value)
172172
*/
173173
public function actionSubmit()
174174
{
175-
return $this->action('function() { this.submit(); }');
175+
$this->attributes['action'] = 'function() { this.submit(); }';
176+
177+
return $this;
176178
}
177179

178180
/**
@@ -183,7 +185,7 @@ public function actionSubmit()
183185
*/
184186
public function action($value)
185187
{
186-
$this->attributes['action'] = $value;
188+
$this->attributes['action'] = "function(e, dt, node, config) { $value }";
187189

188190
return $this;
189191
}
@@ -196,7 +198,9 @@ public function action($value)
196198
*/
197199
public function actionHandler($action)
198200
{
199-
return $this->action("function() { this.submit(null, null, function(data) { data.action = '{$action}'; return data; }) }");
201+
$this->attributes['action'] = "function() { this.submit(null, null, function(data) { data.action = '{$action}'; return data; }) }";
202+
203+
return $this;
200204
}
201205

202206
/**
@@ -206,6 +210,8 @@ public function actionHandler($action)
206210
*/
207211
public function actionClose()
208212
{
209-
return $this->action('function() { this.close(); }');
213+
$this->attributes['action'] = 'function() { this.close(); }';
214+
215+
return $this;
210216
}
211217
}

0 commit comments

Comments
 (0)