Discussion:
[dart-misc] Setting active element in css menu
Mateusz Lewandowski
2016-07-17 20:33:00 UTC
Permalink
Hi
How to add active class form menu item made in html with css like jquery
does this way:

$('li a').click(function(e) {
e.preventDefault();
$('a').removeClass('active');
$(this).addClass('active');
});

for following simple menu?
<ul>
<li>
element
</li>
</ul>

Please help
--
For other discussions, see https://groups.google.com/a/dartlang.org/

For HOWTO questions, visit http://stackoverflow.com/tags/dart

To file a bug report or feature request, go to http://www.dartbug.com/new
---
You received this message because you are subscribed to the Google Groups "Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send an email to misc+***@dartlang.org.
Jan Mostert
2016-07-18 04:59:00 UTC
Permalink
If you want to use jquery-like syntax, have a look at Dquery.

The Dart way is probably to do something like (I'm on my phone, so excuse
syntax errors):

querySelectorAll('a li').forEach(ListElement li){
If (shouldBeActive)
li.classes.add('active');
else
li.classes.clear(); // or try remove as well if you don't want to clear
}
Post by Mateusz Lewandowski
Hi
How to add active class form menu item made in html with css like jquery
$('li a').click(function(e) {
e.preventDefault();
$('a').removeClass('active');
$(this).addClass('active');
});
for following simple menu?
<ul>
<li>
element
</li>
</ul>
Please help
--
For other discussions, see https://groups.google.com/a/dartlang.org/
For HOWTO questions, visit http://stackoverflow.com/tags/dart
To file a bug report or feature request, go to http://www.dartbug.com/new
---
You received this message because you are subscribed to the Google Groups
"Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send an
--
For other discussions, see https://groups.google.com/a/dartlang.org/

For HOWTO questions, visit http://stackoverflow.com/tags/dart

To file a bug report or feature request, go to http://www.dartbug.com/new
---
You received this message because you are subscribed to the Google Groups "Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send an email to misc+***@dartlang.org.
Jan Mostert
2016-07-18 05:01:23 UTC
Permalink
Forgot to add li.onClick.listen(e){....}
Post by Jan Mostert
If you want to use jquery-like syntax, have a look at Dquery.
The Dart way is probably to do something like (I'm on my phone, so excuse
querySelectorAll('a li').forEach(ListElement li){
If (shouldBeActive)
li.classes.add('active');
else
li.classes.clear(); // or try remove as well if you don't want to clear
}
Post by Mateusz Lewandowski
Hi
How to add active class form menu item made in html with css like jquery
$('li a').click(function(e) {
e.preventDefault();
$('a').removeClass('active');
$(this).addClass('active');
});
for following simple menu?
<ul>
<li>
element
</li>
</ul>
Please help
--
For other discussions, see https://groups.google.com/a/dartlang.org/
For HOWTO questions, visit http://stackoverflow.com/tags/dart
To file a bug report or feature request, go to http://www.dartbug.com/new
---
You received this message because you are subscribed to the Google Groups
"Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send an
--
For other discussions, see https://groups.google.com/a/dartlang.org/

For HOWTO questions, visit http://stackoverflow.com/tags/dart

To file a bug report or feature request, go to http://www.dartbug.com/new
---
You received this message because you are subscribed to the Google Groups "Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send an email to misc+***@dartlang.org.
Mateusz Lewandowski
2016-07-18 06:13:30 UTC
Permalink
Thanks a lot for your response.
But how can i determine which element from the list item was clicked in
dart approach?
I need this for set active class for proper element
Post by Jan Mostert
Forgot to add li.onClick.listen(e){....}
Post by Jan Mostert
If you want to use jquery-like syntax, have a look at Dquery.
The Dart way is probably to do something like (I'm on my phone, so excuse
querySelectorAll('a li').forEach(ListElement li){
If (shouldBeActive)
li.classes.add('active');
else
li.classes.clear(); // or try remove as well if you don't want to clear
}
On Sun, 17 Jul 2016, 22:33 Mateusz Lewandowski <
Post by Mateusz Lewandowski
Hi
How to add active class form menu item made in html with css like jquery
$('li a').click(function(e) {
e.preventDefault();
$('a').removeClass('active');
$(this).addClass('active');
});
for following simple menu?
<ul>
<li>
element
</li>
</ul>
Please help
--
For other discussions, see https://groups.google.com/a/dartlang.org/
For HOWTO questions, visit http://stackoverflow.com/tags/dart
To file a bug report or feature request, go to
http://www.dartbug.com/new
---
You received this message because you are subscribed to the Google
Groups "Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send
--
For other discussions, see https://groups.google.com/a/dartlang.org/
For HOWTO questions, visit http://stackoverflow.com/tags/dart
To file a bug report or feature request, go to http://www.dartbug.com/new
---
You received this message because you are subscribed to the Google Groups
"Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send an
--
For other discussions, see https://groups.google.com/a/dartlang.org/

For HOWTO questions, visit http://stackoverflow.com/tags/dart

To file a bug report or feature request, go to http://www.dartbug.com/new
---
You received this message because you are subscribed to the Google Groups "Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send an email to misc+***@dartlang.org.
Jan Mostert
2016-07-18 06:23:36 UTC
Permalink
Wrote a quick DartPad example, plenty of scope for improvement, but this
should give you and idea:
https://dartpad.dartlang.org/2d08514213aeadfe8345d5882fdb669e
Post by Mateusz Lewandowski
Thanks a lot for your response.
But how can i determine which element from the list item was clicked in
dart approach?
I need this for set active class for proper element
Post by Jan Mostert
Forgot to add li.onClick.listen(e){....}
Post by Jan Mostert
If you want to use jquery-like syntax, have a look at Dquery.
The Dart way is probably to do something like (I'm on my phone, so
querySelectorAll('a li').forEach(ListElement li){
If (shouldBeActive)
li.classes.add('active');
else
li.classes.clear(); // or try remove as well if you don't want to clear
}
On Sun, 17 Jul 2016, 22:33 Mateusz Lewandowski <
Post by Mateusz Lewandowski
Hi
How to add active class form menu item made in html with css like
$('li a').click(function(e) {
e.preventDefault();
$('a').removeClass('active');
$(this).addClass('active');
});
for following simple menu?
<ul>
<li>
element
</li>
</ul>
Please help
--
For other discussions, see https://groups.google.com/a/dartlang.org/
For HOWTO questions, visit http://stackoverflow.com/tags/dart
To file a bug report or feature request, go to
http://www.dartbug.com/new
---
You received this message because you are subscribed to the Google
Groups "Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send
--
For other discussions, see https://groups.google.com/a/dartlang.org/
For HOWTO questions, visit http://stackoverflow.com/tags/dart
To file a bug report or feature request, go to http://www.dartbug.com/new
---
You received this message because you are subscribed to the Google Groups
"Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send an
--
For other discussions, see https://groups.google.com/a/dartlang.org/
For HOWTO questions, visit http://stackoverflow.com/tags/dart
To file a bug report or feature request, go to http://www.dartbug.com/new
---
You received this message because you are subscribed to the Google Groups
"Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send an
--
For other discussions, see https://groups.google.com/a/dartlang.org/

For HOWTO questions, visit http://stackoverflow.com/tags/dart

To file a bug report or feature request, go to http://www.dartbug.com/new
---
You received this message because you are subscribed to the Google Groups "Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send an email to misc+***@dartlang.org.
Mateusz Lewandowski
2016-07-27 17:24:40 UTC
Permalink
thanks a lot
sory for late
Post by Jan Mostert
Wrote a quick DartPad example, plenty of scope for improvement, but this
https://dartpad.dartlang.org/2d08514213aeadfe8345d5882fdb669e
On Mon, 18 Jul 2016 at 08:13 Mateusz Lewandowski <
Post by Mateusz Lewandowski
Thanks a lot for your response.
But how can i determine which element from the list item was clicked in
dart approach?
I need this for set active class for proper element
Post by Jan Mostert
Forgot to add li.onClick.listen(e){....}
Post by Jan Mostert
If you want to use jquery-like syntax, have a look at Dquery.
The Dart way is probably to do something like (I'm on my phone, so
querySelectorAll('a li').forEach(ListElement li){
If (shouldBeActive)
li.classes.add('active');
else
li.classes.clear(); // or try remove as well if you don't want to clear
}
On Sun, 17 Jul 2016, 22:33 Mateusz Lewandowski <
Post by Mateusz Lewandowski
Hi
How to add active class form menu item made in html with css like
$('li a').click(function(e) {
e.preventDefault();
$('a').removeClass('active');
$(this).addClass('active');
});
for following simple menu?
<ul>
<li>
element
</li>
</ul>
Please help
--
For other discussions, see https://groups.google.com/a/dartlang.org/
For HOWTO questions, visit http://stackoverflow.com/tags/dart
To file a bug report or feature request, go to
http://www.dartbug.com/new
---
You received this message because you are subscribed to the Google
Groups "Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send
--
For other discussions, see https://groups.google.com/a/dartlang.org/
For HOWTO questions, visit http://stackoverflow.com/tags/dart
To file a bug report or feature request, go to
http://www.dartbug.com/new
---
You received this message because you are subscribed to the Google
Groups "Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send
--
For other discussions, see https://groups.google.com/a/dartlang.org/
For HOWTO questions, visit http://stackoverflow.com/tags/dart
To file a bug report or feature request, go to http://www.dartbug.com/new
---
You received this message because you are subscribed to the Google Groups
"Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send an
--
For other discussions, see https://groups.google.com/a/dartlang.org/
For HOWTO questions, visit http://stackoverflow.com/tags/dart
To file a bug report or feature request, go to http://www.dartbug.com/new
---
You received this message because you are subscribed to the Google Groups
"Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send an
--
For other discussions, see https://groups.google.com/a/dartlang.org/

For HOWTO questions, visit http://stackoverflow.com/tags/dart

To file a bug report or feature request, go to http://www.dartbug.com/new
---
You received this message because you are subscribed to the Google Groups "Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send an email to misc+***@dartlang.org.
Continue reading on narkive:
Loading...