-
-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Use <button> instead of <a> for JavaScript interactive buttons #9892
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
Conversation
This removes the need to call `preventDefault()` to disable the default action of <a> elements, since <button type="button"> has no default action whatsoever.
@Calinou this looks really nice to me! Thank you. I'll give some time before merging so others can review and comment on 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.
Thanks for this PR!
Thanks Hugo. |
…ttons (Calinou) This PR was merged into the 2.8 branch. Discussion ---------- Use <button> instead of <a> for JavaScript interactive buttons This removes the need to call `preventDefault()` to disable the default action of `<a>` elements, since `<button type="button">` has no default action whatsoever. See also [this Stack Overflow question](https://stackoverflow.com/questions/469059/button-vs-input-type-button-which-to-use) about the `<button>` HTML tag. Commits ------- 87db1b6 Use <button> instead of <a> for JavaScript interactive buttons
@@ -353,8 +353,8 @@ will be show next): | |||
var $collectionHolder; | |||
|
|||
// setup an "add a tag" link | |||
var $addTagLink = $('<a href="#" class="add_tag_link">Add a tag</a>'); | |||
var $newLinkLi = $('<li></li>').append($addTagLink); | |||
var $addTagButton = $('<button type="button" class="add_tag_link">Add a tag</a>'); |
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.
The closing tag should be updated as well: <button>...</a>
$removeFormA.on('click', function(e) { | ||
// prevent the link from creating a "#" on the URL | ||
e.preventDefault(); | ||
var $removeFormButton = $('<button type="button">Delete this tag</a>'); |
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.
Here as well
Both inline comments adressed in #9911 |
This removes the need to call
preventDefault()
to disable the default action of<a>
elements, since<button type="button">
has no default action whatsoever.See also this Stack Overflow question about the
<button>
HTML tag.