make action on polymer menu item clicked(coumicating from inside polymer element to html page)

64 views
Skip to first unread message

Mateusz Lewandowski

unread,
Sep 22, 2016, 5:11:42 AM9/22/16
to Dart Misc
Hi. I am searching for method how to change content of my html page(in some div), when i click on the menu item (defined by myself not core menu etc...) in my polymer element.
Is there any easy way to do this. Soomething like calling event and handilng it in main.dart of html page would be great but i do not know how to achieve that.
I hope that You help me

Jonas Bojesen

unread,
Sep 22, 2016, 12:48:06 PM9/22/16
to Dart Misc

Mateusz Lewandowski

unread,
Sep 22, 2016, 3:19:32 PM9/22/16
to mi...@dartlang.org
My menu could by something like https://elements.polymer-project.org/elements/iron-pages
but i need to handle selected item in menu from this class
How to fire event from polymer element and handle it in typical dart in main function?
@CustomTag('mainmenu-element')
class MainMenu extends PolymerElement {
// MainMenu.created() : super.created();
@observable bool isLogged=false;
@observable List menuElements = toObservable(['Home', 'News', 'Contact', 'About']);
@observable var elements = {
"Ogloszenia": "link",
"Logowanie": "link",
"Rejestracja": "rejestracja",
"O stronie": "ostronie"
};
var previous;

MainMenu.created() : super.created()
{
var storage=window.localStorage['authentication'];
if(storage!=null) {
this.isLogged = true;
}
}

void SelectItem(event, detail, target) {
if(previous!=null) {
previous.classes.remove('active');
}
target.classes.add('active');
this.previous=target;
}
}

--
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+uns...@dartlang.org.

Jonas Bojesen

unread,
Sep 28, 2016, 10:37:45 PM9/28/16
to Dart Misc
When a menu item is selected an iron-select event is fired by the framwork. Listed at section Events https://elements.polymer-project.org/elements/iron-menu-behavior

I would solve this by putting the menu and the iron-pages into same element and bind the selected properties of them both to the same variable, just my preference. A solution with events will also work.
Reply all
Reply to author
Forward
0 new messages