Skip to content

Commit ead9a40

Browse files
committed
Operation: Fixed setConfirm client side [Closed #137]
1 parent c7eec65 commit ead9a40

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

Grido/Components/Operation.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public function setConfirm($operation, $message)
6767
{
6868
$message = $this->translate($message);
6969
$this->grid->onRender[] = function(Grid $grid) use ($operation, $message) {
70-
$grid['form'][Operation::ID][Operation::ID]->controlPrototype->data["grido-$operation"] = $message;
70+
$grid['form'][Operation::ID][Operation::ID]->controlPrototype->data["grido-confirm-$operation"] = $message;
7171
};
7272

7373
return $this;

client-side/grido.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@
341341

342342
onSubmit: function()
343343
{
344-
var hasConfirm = this.getSelect().data('grido-' + this.getSelect().val());
344+
var hasConfirm = this.getSelect().attr('data-grido-confirm-' + this.getSelect().val());
345345
if (hasConfirm) {
346346
if (confirm(hasConfirm.replace(/%i/g, $(this.selector + ':checked', this.grido.$table).length))) {
347347
return true;

tests/Grido/Components/Operation.phpt

+3-3
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,13 @@ class OperationTest extends \Tester\TestCase
2323
Helper::grid(function(Grid $grid) {
2424
$grid->setModel(array());
2525
$grid->addColumnText('column', 'Column');
26-
$grid->setOperation(array('edit' => 'Edit', 'del' => 'Del'), function() {})
27-
->setConfirm('del', 'Are you sure?');
26+
$grid->setOperation(array('edit' => 'Edit', 'delete' => 'Delete'), function() {})
27+
->setConfirm('delete', 'Are you sure?');
2828
$grid->render();
2929
})->run();
3030

3131
$formControl = Helper::$grid['form'][Operation::ID][Operation::ID];
32-
Assert::same($formControl->controlPrototype->data['grido-del'], 'Are you sure?');
32+
Assert::same($formControl->controlPrototype->data['grido-confirm-delete'], 'Are you sure?');
3333
}
3434

3535
/**********************************************************************************************/

0 commit comments

Comments
 (0)