-
Notifications
You must be signed in to change notification settings - Fork 106
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix/#746 Duplicate button and icon id #747
Conversation
Codecov Report
@@ Coverage Diff @@
## develop #747 +/- ##
=========================================
Coverage ? 66.1%
Complexity ? 2226
=========================================
Files ? 118
Lines ? 5243
Branches ? 0
=========================================
Hits ? 3466
Misses ? 1777
Partials ? 0
Continue to review full report at Codecov.
|
Will this ensure the element is unique enough? The one genererated in the class attribute is not unique, it repeats every row anyway. |
@pkly - This will ensure that the id attribute for button and icon is set to null and not get duplicate with a generic name like 'atk'. The class attribute name that get duplicate for each button is used as a selector for adding the click handler to the button.
This will send the row data-id with each callback when button is click. Perhaps I do not see the use case to generate a unique id's for each button. Why do you need to set a unique id for each one's in table? There would be a way to do so but that will require for you to pass your own button object. For example using your own CRUD class your can override initUpdate and initDelete to set your own button:
This will generate a template row for the table and the tag {$_id} would be replace with your model id as an example generating something like
|
Wouldn't that break the actions with on, like $myButton = $grid->addAction(['icon' => 'whatever']);
$myButton->on('click', function($a) {
// whatever
}); Don't the js chains rely pretty much only on IDs of elements? |
i think the correct fix would be to make This annoying bit has been there for some time, but i was afraid to fix due to BC, now is a good time! |
This can also fix: https://github.com/atk4/ui/blob/develop/src/Form.php#L303 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
implement id=>false properly.
I see, although $grid->addAction($name, $function) return a button and that you can still add a js_action to it. However, js_action added to it will not be render, probably because Table is in fact a Lister and the button is not an element of the table directly. I guess the only reason why a button is returned via Grid::addAction() method is to be able to modify button look. |
We can use custom selector on jsAction. Something similar to Field->jsInput() |
add property for defaultName
@romaninsh
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is perfect, thanks!
Fix #746