-
Notifications
You must be signed in to change notification settings - Fork 6.1k
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
Expand customizable cells to all views #2124
base: master
Are you sure you want to change the base?
Expand customizable cells to all views #2124
Conversation
Azaret
commented
Feb 14, 2017
•
edited
Loading
edited
Q | A |
---|---|
Bug fix? | no |
New feature? | rather enhancement |
BC breaks? | no |
Related tickets | fixes #2120, partially #2043 |
License | MIT |
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.
WIP
@vsn4ik I took the liberty to enhance your idea. |
Attaching the event directly to the node was in my mind for the v2. |
@acrobat Fill free to play around to be sure I didn't break everything. Some snippet for your amusement: function callback() {
var smileys = ['😁', '😋', '😡', '😰', '🙅', '🙊', '🙏', '✌', '🚀', '🚨', '🚧', '🚽', '🉐', '⌚', '☝', '⚽', '⚾', '⛄', '⛅'];
return {content: '<div>' + smileys[Math.floor(Math.random() * smileys.length)] + '</div>'};
}
$('input').datepicker({
beforeShowDay: callback,
beforeShowMonth: callback,
beforeShowYear: callback,
beforeShowDecade: callback,
beforeShowCentury: callback
}); |
@Azaret Do we need extra tests for this behavior (the changes to the click etc) or is it covered by the current tests? |
node.data('date', {day: 1, month: i, year: this.viewDate.getUTCFullYear()}); | ||
node.attr('class', 'month' + focused); | ||
node.html(dates[this.o.language].monthsShort[i]); | ||
node.on('click', $.proxy(this.cellClick, this)); |
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.
No, it is bad practice.
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.
Why ?
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.
If you follow your rule will turn 90 listeners: (4 * 12) + 42 (days) = 90
. Is not critical, it is possible to leave.
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.
Is this comment fixed?
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.
Yeah I though about it the other day and it hit me what @vsn4ik was talking about.
The issue is that by design it is not easy to catch the event when the DOM is customized.
Comprehensive drawing:
Before it was easy, you can bind on the container, and get the source of the event with currentTarget
.
Now currentTarget
will return the custom DOM nodes instead of the td cell.
The easiest and safest way is then to bind the event to the cell, so target
will equals the cell, always.
If we keep the event bound to the container, it mean we'll have to lookup for the cell between the target
and the currentTarget
.
So the question is, which is the best performance wise between binding 90 events or recursively find a DOM element.
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.
Ok that explains a lot! So we should go for the 90 events for now? What do you think @vsn4ik?
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.
Ping @vsn4ik
Well it looks clear to me, I'm waiting @vsn4ik input on his remarks. |
Hmm he had posted a comment, but it looks like it was deleted. So indeed wait for @vsn4ik for his feedback |
When is this expected to come out? According to the docs, returning an object with a content key in the beforeShowDay method should allow me to change the content, however it does not work. I can disable a day fine with a boolean, just can't set content. @Azaret @acrobat @vsn4ik edit* I realized this isn't enabled in the version I am using (1.6.4) and I could change the docs based on version :) thanks to everyone contributing to this |
@Azaret sorry to ping you again! But any more work needed here? If I understand your comment above correctly "90 events" choice we have to make is good enough for now? If we can agree on some solution for this would be nice, this way I can put out a RC2 ( and hopefully quite quick a stable release) /cc @vsn4ik |