-
Notifications
You must be signed in to change notification settings - Fork 343
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
UI: cleanup magic for signal-mechanism #578
UI: cleanup magic for signal-mechanism #578
Conversation
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.
Thanks a lot for those improvements! Maybe a short comment on why this approach is superior will help devs. in future (see comment).
$show = $modal->getShowSignal(); | ||
$close = $modal->getCloseSignal(); | ||
$js = $this->getJavascriptBinding(); |
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.
Maybe explain in the comment of this function why this pattern here:
$js = $this->getJavascriptBinding();
$js->addOnLoadCode("
$(document).on('{$show}', function() { il.UI.modal.showModal('{$id}', {$options}); return false; });
$(document).on('{$close}', function() { il.UI.modal.closeModal('{$id}'); return false; });"
);
Is bad and should not be used and refer to this pattern:
return $modal->withAdditionalOnLoadCode(function($id) use (...) {
return ...
});
To be used instead.
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.
There you go.
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.
Thanks for the cleanup. One thing I'm not sure of: Now it is no longer possible for a renderer to get a unique ID without binding some javascript. In my opinion, this possibility should still exist. A component may want to easily identify another part in the DOM (part of its template) via ID.
@wanze: lets wait for the use case =) |
@alex40724 Wanna have a look into this? I messed around (a little) with you drop down. If not, I'll merge. |
@klees Actually I have a use case for the upcoming dropzones, but one can easily work around it ;-) Just to explain what I mean: Dropzones use a container to display the dropped files. Depending of the type of a dropzone, this container may be below the dropzone or in a modal. If it is possible to create an ID for this container, I can directly reference it in JQuery via:
Otherwise, I need to find my container with the knowledge where it exists in the DOM, e.g.
Thus, if someone decides to move the file listing container in the dropzone template (e.g. display it above the dropzone), JS will break because it won't find the container anymore. I would prefer to have an ID to identify a component directly. |
@wanze I bet you a beer that even in this case you do not need to generate an id via |
I noticed the opportunity to cleanup some magic that was introduced with the signal-mechanism.
People writing Renderers will now have an easier job.
Triggerable
andTriggerer
need to beJavaScriptBindable
anyway, because they in fact use that functionality. Some internals ofAbstractComponentRenderer
that were exposed during the introduction of the signal-mechanism are back to being internal.