#27533 closed enhancement (fixed)
Unobtrusive JS for "Quick Edit" button at "Comments" page and others
Reported by: | aubreypwd | Owned by: | wonderboymusic |
---|---|---|---|
Milestone: | 4.0 | Priority: | normal |
Severity: | normal | Version: | 3.9 |
Component: | Administration | Keywords: | has-patch commit dev-reviewed |
Focuses: | javascript, administration | Cc: |
Description
In #24741 I fixed the issue where onclick=
was being used to call a function, but it wasn't the ideal fix. We want to fix that instance, and other applicable instances in core (if any), to be unobtrusive if possible.
Attachments (6)
Change History (20)
#2
@
11 years ago
- Keywords has-patch dev-feedback added
I've added a patch to solve #24741 using un-obtrusive JS.
This ticket was mentioned in IRC in #wordpress-dev by aubreypwd. View the logs.
11 years ago
#4
@
11 years ago
@SergeyBiryukov I saw you slated another ticket of mine for 4.0, can we get this one in? I think it's better than what's there.
This ticket was mentioned in IRC in #wordpress-dev by aubreypwd. View the logs.
11 years ago
#6
@
11 years ago
- Keywords needs-patch added; has-patch dev-feedback removed
- Milestone changed from Awaiting Review to 4.0
I like this but it should use event delegation:
$( 'body' ).on( 'click', '.class-name, .other-class', function (e) { e.preventDefault(); var element = $( e.currentTarget ); // whatever } );
#8
@
11 years ago
- Owner set to wonderboymusic
- Resolution set to fixed
- Status changed from new to closed
In 28810:
#9
@
10 years ago
- Resolution fixed deleted
- Status changed from closed to reopened
[28810] does a few particularly weird things:
- It lets things bubble up to the body, rather than using a more direct parent like #the-comment-list or table.comments or whatever.
- It uses a lot of unnecessary cascading:
.comment .row-actions .quickedit .edit-comment-inline
. Something like.edit-comment-inline
should be sufficient. - Why does it use event.currentTarget rather than
this
? - commentReply has to be defined; it's in this JS file. Those checks were only there because it was obtrusive JS and it could have been triggered before this file was loaded.
#10
@
10 years ago
27533.4.diff addresses the above points, all of which I agree with. In particular, I would love to know why there's been a proliferation of event.currentTarget
instead of this
recently, and if there are any specific places that actually need the differentiation.
#11
@
10 years ago
27533.5.diff consolidates the callback.
Using unobtrusive JS on comment "Reply," and "Quick Edit."