-
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
Allow customizing day cell value #2043
Conversation
programcsharp
commented
Oct 24, 2016
Q | A |
---|---|
Bug fix? | no |
New feature? | yes |
BC breaks? | no |
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.
Hi, Thank you for your work. Please don't forget to add some unit tests.
js/bootstrap-datepicker.js
Outdated
@@ -1196,6 +1200,10 @@ | |||
} | |||
|
|||
if (!target.hasClass('disabled')){ | |||
// Allow clicking on elements inside a day | |||
if (target.parent().hasClass('day')) | |||
target = target.parent(); |
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.
Since you allow html, you code won't work if I send <div><div></div></div>
, you should change e.target
by e.currentTarget
, but then you should do a full test to be sure it does not break everything.
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.
I'm not sure that e.currentTarget would work because bubbling/propagation are stopped at the top of the click handler.
Instead, I use .parents(), does that work?
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.
It should I guess
js/bootstrap-datepicker.js
Outdated
@@ -1041,7 +1045,7 @@ | |||
clsName = $.unique(clsName); | |||
} | |||
|
|||
html.push('<td class="'+clsName.join(' ')+'"' + (tooltip ? ' title="'+tooltip+'"' : '') + (this.o.dateCells ? ' data-date="'+(prevMonth.getTime().toString())+'"' : '') + '>'+prevMonth.getUTCDate() + '</td>'); | |||
html.push('<td class="'+clsName.join(' ')+'"' + (tooltip ? ' title="'+tooltip+'"' : '') + (this.o.dateCells ? ' data-date="'+(prevMonth.getTime().toString())+'"' : '') + '>' + displayDate + '</td>'); |
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.
You are actually making the other views sad and envious to the monthView :)
May you add this on the other views please ?
js/bootstrap-datepicker.js
Outdated
@@ -1017,6 +1017,8 @@ | |||
clsName = this.getClassNames(prevMonth); | |||
clsName.push('day'); | |||
|
|||
var displayDate = prevMonth.getUTCDate(); |
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 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.
👍
Add test for content
Add test to check click on custom content
Anything else need done here? |
js/bootstrap-datepicker.js
Outdated
@@ -1196,6 +1200,12 @@ | |||
} | |||
|
|||
if (!target.hasClass('disabled')){ | |||
// Allow clicking on elements inside a day | |||
var day = target.parents('.day'); |
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.
Day is already defined on line 1183, see travis build
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.
Fixed.
Yeah, I would like to see the same feature for the others views (month, year, decade, ...) lookup for |
OK, I can do that for consistency and all that goodness. I'll fix the var name too. Do you have a better suggestion for how to handle deeply nested clicks? I can duplicate the same thing I did for day -- |
Do it for the fame ;)
|
Being able to customize content within each day would be really awesome. I am trying to display counts of something in each day but haven't been able to figure out how. |
@Azaret Can you review the pull request again? Thanks! |
@programcsharp I would like to get this PR finished and have it shipped with 1.7.0! 🚀 Do you need to do any work here? Please rebase the branch against the current mast and can you check the failing travis build? Thanks! @Azaret Time for a last review? Thanks! |
OK, lemme see what I can do here. |
…epicker into custom-day-display # Conflicts: # js/bootstrap-datepicker.js
Fixed the dupe variable name issue @Azaret mentioned. Should be ready to go now. I don't have time to add the month/year/decade/century implementations. |
Thanks @programcsharp! I will look into this to see what I can do to have this feature shipped with 1.7.0 |
I guess we can push it in RC2 @acrobat |
@Azaret Yes I will merge this today and tag a new RC release. But we need to try to implement this feature for all beforeXxx methods, I hope to find some time for this! |
Thanks @programcsharp! The missing parts for beforeShowMonth (yeay, decade, etc) will be done in #2120 |