Closed jandudulski closed 10 years ago
input type="submit"
is good too, but button type="button"
is crucial for buttons inside form that are not dedicated to submitting of this form.
Seems legit.
ok
I'll just add that it's important to add type="button"
because this attribute defaults to submit
so just button
will try to send the form.
What if I need to use <a>
tag combined with ng-click="foo()"
, what should I put inside href attribute?
href=""
href="javascript:void(0)"
In many places the last option is suggested
cc: @venticco @hodak @tommy92 @jandudulski @teamon
If you need to have ng-click
action, then you should use <button>
, if it need look and behavior of link then use CSS to make it looks like one. <a>
without href
attribute is improper, empty href
can lead into wrong behavior, and last option looks and feels ugly, because of inline JS code.
Yeah it's ugly hack, I know... the problem is that bootstrap uses <a>
tags in the components like dropdowns. I would have to change CSS to use buttons.
Hmm, that's a good point. I think in this case it's justified to use a
. Do you know the reason behind the javascript:void(0)
and why it would be better than href=""
?
Not really. Maybe we should combine href=""
with prevent-default
directive in such cases?
@tallica drop the bootstrap :smile:
Use anchor (
a
HTML tag element) when click should change page url. Usebutton type="submit"
if click would submit a form. Usebutton type="button"
for any other click actions (e.g. next page with ajax loading, toggle view etc).