Discussion:
[dart-misc] Adding buttons dynamicly with action on click
Mateusz Lewandowski
2016-10-05 07:47:21 UTC
Permalink
Hi, I have a problem with creating table with buttons inside one of the
columns.
I need to take appropriate action on click with ID parameter inside
function on click.
The problem is that on click function is executing to fast after table load
on the html page.
This is my code:

Future LoadData() async
{
DivElement tableDiv=new DivElement();
tableDiv.classes.add("table");
TableElement table=new TableElement();

var tBody = table.createTBody();
var tHead=table.createTHead();
var advertisments=JSON.decode(await dataExchange.loadData("api/GetData"));
int counter=0;

var head=tHead.addRow();
head.insertCell(0).text="1";
head.insertCell(1).text="2";
head.insertCell(2).text="3";
head.insertCell(3).text="4";

advertisments.forEach((item)
{
ButtonElement btn=new ButtonElement();

var line=tBody.insertRow(counter);
line.insertCell(0).text = item["data1"];
line.insertCell(1).text = item["data2"];
line.insertCell(2).text = item["data3"];

int Id=item["Id"];
btn.onClick.listen(LoadDetails(Id.toString()));

btn.text="action button";
line.insertCell(3).nodes.add(btn);

counter++;
});
tableDiv.nodes.add(table);

querySelector("#Content").setInnerHtml(tableDiv.outerHtml);

}

void LoadDetails(var id)
{
print("test "+id);
}


Have you any idea how to solve this problem?
--
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.
Alexandre Maurel
2016-10-05 07:57:35 UTC
Permalink
try that

btn.onClick.listen((evt)=>LoadDetails(Id.toString()));
Post by Mateusz Lewandowski
Hi, I have a problem with creating table with buttons inside one of
the columns.
I need to take appropriate action on click with ID parameter inside
function on click.
The problem is that on click function is executing to fast after table
load on the html page.
Future LoadData()async {
DivElement tableDiv=new DivElement();
tableDiv.classes.add("table");
TableElement table=new TableElement();
var tBody = table.createTBody();
var tHead=table.createTHead();
var advertisments=JSON.decode(await dataExchange.loadData("api/GetData"));
int counter=0;var head=tHead.addRow();
head.insertCell(0).text="1";
head.insertCell(1).text="2";
head.insertCell(2).text="3";
head.insertCell(3).text="4";
advertisments.forEach((item)
{
ButtonElement btn=new ButtonElement();
var line=tBody.insertRow(counter);
line.insertCell(0).text = item["data1"];
line.insertCell(1).text = item["data2"];
line.insertCell(2).text = item["data3"];
int Id=item["Id"];
btn.onClick.listen(LoadDetails(Id.toString()));
btn.text="action button";
line.insertCell(3).nodes.add(btn);
counter++;
});
tableDiv.nodes.add(table);querySelector("#Content").setInnerHtml(tableDiv.outerHtml);
}
void LoadDetails(var id)
{
print("test "+id);
}
Have you any idea how to solve this problem?
-- 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
--
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-10-05 20:29:55 UTC
Permalink
Does not work, even function is not executed as in previous version when
function was executing before button click
Post by Alexandre Maurel
try that
btn.onClick.listen((evt)=>LoadDetails(Id.toString()));
Hi, I have a problem with creating table with buttons inside one of the
columns.
I need to take appropriate action on click with ID parameter inside
function on click.
The problem is that on click function is executing to fast after table
load on the html page.
Future LoadData() async{
DivElement tableDiv=new DivElement();
tableDiv.classes.add("table");
TableElement table=new TableElement();
var tBody = table.createTBody();
var tHead=table.createTHead();
var advertisments=JSON.decode(await dataExchange.loadData("api/GetData"));
int counter=0; var head=tHead.addRow();
head.insertCell(0).text="1";
head.insertCell(1).text="2";
head.insertCell(2).text="3";
head.insertCell(3).text="4";
advertisments.forEach((item)
{
ButtonElement btn=new ButtonElement();
var line=tBody.insertRow(counter);
line.insertCell(0).text = item["data1"];
line.insertCell(1).text = item["data2"];
line.insertCell(2).text = item["data3"];
int Id=item["Id"];
btn.onClick.listen(LoadDetails(Id.toString()));
btn.text="action button";
line.insertCell(3).nodes.add(btn);
counter++; }); tableDiv.nodes.add(table); querySelector("#Content").setI
nnerHtml(tableDiv.outerHtml); } void LoadDetails(var id) { print("test "+id);
}
Have you any idea how to solve this problem?
-- 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
--
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-10-05 21:47:38 UTC
Permalink
When I have saved generated buttons into List<ButtonElements> and tried
click in debugger like buttons[0].click() the event was rised.
It sems that when i am clicking on button the click event is not rised but
the question is why.
Post by Mateusz Lewandowski
Does not work, even function is not executed as in previous version when
function was executing before button click
Post by Alexandre Maurel
try that
btn.onClick.listen((evt)=>LoadDetails(Id.toString()));
Hi, I have a problem with creating table with buttons inside one of the
columns.
I need to take appropriate action on click with ID parameter inside
function on click.
The problem is that on click function is executing to fast after table
load on the html page.
Future LoadData() async{
DivElement tableDiv=new DivElement();
tableDiv.classes.add("table");
TableElement table=new TableElement();
var tBody = table.createTBody();
var tHead=table.createTHead();
var advertisments=JSON.decode(await dataExchange.loadData("api/GetData"));
int counter=0; var head=tHead.addRow();
head.insertCell(0).text="1";
head.insertCell(1).text="2";
head.insertCell(2).text="3";
head.insertCell(3).text="4";
advertisments.forEach((item)
{
ButtonElement btn=new ButtonElement();
var line=tBody.insertRow(counter);
line.insertCell(0).text = item["data1"];
line.insertCell(1).text = item["data2"];
line.insertCell(2).text = item["data3"];
int Id=item["Id"];
btn.onClick.listen(LoadDetails(Id.toString()));
btn.text="action button";
line.insertCell(3).nodes.add(btn);
counter++; }); tableDiv.nodes.add(table); querySelector("#Content").setI
nnerHtml(tableDiv.outerHtml); } void LoadDetails(var id) { print("test "+id);
}
Have you any idea how to solve this problem?
-- 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
--
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-10-05 22:05:30 UTC
Permalink
maybe it does not work cause of it is inside tables's cell?
Post by Mateusz Lewandowski
When I have saved generated buttons into List<ButtonElements> and tried
click in debugger like buttons[0].click() the event was rised.
It sems that when i am clicking on button the click event is not rised but
the question is why.
Post by Mateusz Lewandowski
Does not work, even function is not executed as in previous version when
function was executing before button click
Post by Alexandre Maurel
try that
btn.onClick.listen((evt)=>LoadDetails(Id.toString()));
Hi, I have a problem with creating table with buttons inside one of the
columns.
I need to take appropriate action on click with ID parameter inside
function on click.
The problem is that on click function is executing to fast after table
load on the html page.
Future LoadData() async{
DivElement tableDiv=new DivElement();
tableDiv.classes.add("table");
TableElement table=new TableElement();
var tBody = table.createTBody();
var tHead=table.createTHead();
var advertisments=JSON.decode(await dataExchange.loadData("api/GetData"));
int counter=0; var head=tHead.addRow();
head.insertCell(0).text="1";
head.insertCell(1).text="2";
head.insertCell(2).text="3";
head.insertCell(3).text="4";
advertisments.forEach((item)
{
ButtonElement btn=new ButtonElement();
var line=tBody.insertRow(counter);
line.insertCell(0).text = item["data1"];
line.insertCell(1).text = item["data2"];
line.insertCell(2).text = item["data3"];
int Id=item["Id"];
btn.onClick.listen(LoadDetails(Id.toString()));
btn.text="action button";
line.insertCell(3).nodes.add(btn);
counter++; }); tableDiv.nodes.add(table); querySelector("#Content").setI
nnerHtml(tableDiv.outerHtml); } void LoadDetails(var id) { print("test "+id);
}
Have you any idea how to solve this problem?
-- 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
--
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 email to misc+***@dartlang.org.
'Harry Terkelsen' via Dart Misc
2016-10-06 16:23:56 UTC
Permalink
Your problem is this line:

querySelector("#Content").setInnerHtml(tableDiv.outerHtml);



You are setting the innerHtml of the '#Content' div with the outerHtml of
tableDiv. The outerHtml is just a string, it knows nothing about the actual
elements that the string represents. So you are subscribed to click events
to button elements that aren't in your html.

You can fix this by doing this instead:

querySelector("#Content").children.add(tableDiv);



On Wed, Oct 5, 2016 at 3:05 PM Mateusz Lewandowski <
Post by Mateusz Lewandowski
maybe it does not work cause of it is inside tables's cell?
When I have saved generated buttons into List<ButtonElements> and tried
click in debugger like buttons[0].click() the event was rised.
It sems that when i am clicking on button the click event is not rised but
the question is why.
Does not work, even function is not executed as in previous version when
function was executing before button click
try that
btn.onClick.listen((evt)=>LoadDetails(Id.toString()));
Hi, I have a problem with creating table with buttons inside one of the
columns.
I need to take appropriate action on click with ID parameter inside
function on click.
The problem is that on click function is executing to fast after table
load on the html page.
Future LoadData() async{
DivElement tableDiv=new DivElement();
tableDiv.classes.add("table");
TableElement table=new TableElement();
var tBody = table.createTBody();
var tHead=table.createTHead();
var advertisments=JSON.decode(await dataExchange.loadData("api/GetData"));
int counter=0; var head=tHead.addRow();
head.insertCell(0).text="1";
head.insertCell(1).text="2";
head.insertCell(2).text="3";
head.insertCell(3).text="4";
advertisments.forEach((item)
{
ButtonElement btn=new ButtonElement();
var line=tBody.insertRow(counter);
line.insertCell(0).text = item["data1"];
line.insertCell(1).text = item["data2"];
line.insertCell(2).text = item["data3"];
int Id=item["Id"];
btn.onClick.listen(LoadDetails(Id.toString()));
btn.text="action button";
line.insertCell(3).nodes.add(btn);
counter++; }); tableDiv.nodes.add(table); querySelector("#Content"
).setInnerHtml(tableDiv.outerHtml); } void LoadDetails(var id) { print("test
"+id); }
Have you any idea how to solve this problem?
-- 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
--
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-10-06 18:35:44 UTC
Permalink
Still does not work.
Maybe the problem is that I am adding event listeners for buttons in class
instead instead in the main directly?

2016-10-06 18:23 GMT+02:00 'Harry Terkelsen' via Dart Misc <
Post by Mateusz Lewandowski
querySelector("#Content").setInnerHtml(tableDiv.outerHtml);
You are setting the innerHtml of the '#Content' div with the outerHtml of
tableDiv. The outerHtml is just a string, it knows nothing about the actual
elements that the string represents. So you are subscribed to click events
to button elements that aren't in your html.
querySelector("#Content").children.add(tableDiv);
On Wed, Oct 5, 2016 at 3:05 PM Mateusz Lewandowski <
Post by Mateusz Lewandowski
maybe it does not work cause of it is inside tables's cell?
2016-10-05 23:47 GMT+02:00 Mateusz Lewandowski <
When I have saved generated buttons into List<ButtonElements> and tried
click in debugger like buttons[0].click() the event was rised.
It sems that when i am clicking on button the click event is not rised
but the question is why.
2016-10-05 22:29 GMT+02:00 Mateusz Lewandowski <
Does not work, even function is not executed as in previous version when
function was executing before button click
try that
btn.onClick.listen((evt)=>LoadDetails(Id.toString()));
Hi, I have a problem with creating table with buttons inside one of the
columns.
I need to take appropriate action on click with ID parameter inside
function on click.
The problem is that on click function is executing to fast after table
load on the html page.
Future LoadData() async{
DivElement tableDiv=new DivElement();
tableDiv.classes.add("table");
TableElement table=new TableElement();
var tBody = table.createTBody();
var tHead=table.createTHead();
var advertisments=JSON.decode(await dataExchange.loadData("api/GetData"));
int counter=0; var head=tHead.addRow();
head.insertCell(0).text="1";
head.insertCell(1).text="2";
head.insertCell(2).text="3";
head.insertCell(3).text="4";
advertisments.forEach((item)
{
ButtonElement btn=new ButtonElement();
var line=tBody.insertRow(counter);
line.insertCell(0).text = item["data1"];
line.insertCell(1).text = item["data2"];
line.insertCell(2).text = item["data3"];
int Id=item["Id"];
btn.onClick.listen(LoadDetails(Id.toString()));
btn.text="action button";
line.insertCell(3).nodes.add(btn);
counter++; }); tableDiv.nodes.add(table); querySelector("#Content").
setInnerHtml(tableDiv.outerHtml); } void LoadDetails(var id) { print("test
"+id); }
Have you any idea how to solve this problem?
-- 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
--
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
--
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-10-06 18:36:46 UTC
Permalink
I mean that functionality which i listed in my first post is in this class.
Post by Mateusz Lewandowski
Still does not work.
Maybe the problem is that I am adding event listeners for buttons in class
instead instead in the main directly?
2016-10-06 18:23 GMT+02:00 'Harry Terkelsen' via Dart Misc <
Post by Mateusz Lewandowski
querySelector("#Content").setInnerHtml(tableDiv.outerHtml);
You are setting the innerHtml of the '#Content' div with the outerHtml of
tableDiv. The outerHtml is just a string, it knows nothing about the actual
elements that the string represents. So you are subscribed to click events
to button elements that aren't in your html.
querySelector("#Content").children.add(tableDiv);
On Wed, Oct 5, 2016 at 3:05 PM Mateusz Lewandowski <
Post by Mateusz Lewandowski
maybe it does not work cause of it is inside tables's cell?
2016-10-05 23:47 GMT+02:00 Mateusz Lewandowski <
When I have saved generated buttons into List<ButtonElements> and tried
click in debugger like buttons[0].click() the event was rised.
It sems that when i am clicking on button the click event is not rised
but the question is why.
2016-10-05 22:29 GMT+02:00 Mateusz Lewandowski <
Does not work, even function is not executed as in previous version when
function was executing before button click
try that
btn.onClick.listen((evt)=>LoadDetails(Id.toString()));
Hi, I have a problem with creating table with buttons inside one of the
columns.
I need to take appropriate action on click with ID parameter inside
function on click.
The problem is that on click function is executing to fast after table
load on the html page.
Future LoadData() async{
DivElement tableDiv=new DivElement();
tableDiv.classes.add("table");
TableElement table=new TableElement();
var tBody = table.createTBody();
var tHead=table.createTHead();
var advertisments=JSON.decode(await dataExchange.loadData("api/GetData"));
int counter=0; var head=tHead.addRow();
head.insertCell(0).text="1";
head.insertCell(1).text="2";
head.insertCell(2).text="3";
head.insertCell(3).text="4";
advertisments.forEach((item)
{
ButtonElement btn=new ButtonElement();
var line=tBody.insertRow(counter);
line.insertCell(0).text = item["data1"];
line.insertCell(1).text = item["data2"];
line.insertCell(2).text = item["data3"];
int Id=item["Id"];
btn.onClick.listen(LoadDetails(Id.toString()));
btn.text="action button";
line.insertCell(3).nodes.add(btn);
counter++; }); tableDiv.nodes.add(table); querySelector("#Content").setI
nnerHtml(tableDiv.outerHtml); } void LoadDetails(var id) { print("test "+id);
}
Have you any idea how to solve this problem?
-- 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
--
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 email to misc+***@dartlang.org.
'Harry Terkelsen' via Dart Misc
2016-10-06 18:38:28 UTC
Permalink
It works for me. I wrote up your example in dartpad:
https://dartpad.dartlang.org/11d9d67caef3f15cbac49042ae5ea945

On Thu, Oct 6, 2016 at 11:36 AM Mateusz Lewandowski <
Post by Mateusz Lewandowski
I mean that functionality which i listed in my first post is in this class.
Still does not work.
Maybe the problem is that I am adding event listeners for buttons in class
instead instead in the main directly?
2016-10-06 18:23 GMT+02:00 'Harry Terkelsen' via Dart Misc <
querySelector("#Content").setInnerHtml(tableDiv.outerHtml);
You are setting the innerHtml of the '#Content' div with the outerHtml of
tableDiv. The outerHtml is just a string, it knows nothing about the actual
elements that the string represents. So you are subscribed to click events
to button elements that aren't in your html.
querySelector("#Content").children.add(tableDiv);
On Wed, Oct 5, 2016 at 3:05 PM Mateusz Lewandowski <
maybe it does not work cause of it is inside tables's cell?
When I have saved generated buttons into List<ButtonElements> and tried
click in debugger like buttons[0].click() the event was rised.
It sems that when i am clicking on button the click event is not rised but
the question is why.
Does not work, even function is not executed as in previous version when
function was executing before button click
try that
btn.onClick.listen((evt)=>LoadDetails(Id.toString()));
Hi, I have a problem with creating table with buttons inside one of the
columns.
I need to take appropriate action on click with ID parameter inside
function on click.
The problem is that on click function is executing to fast after table
load on the html page.
Future LoadData() async{
DivElement tableDiv=new DivElement();
tableDiv.classes.add("table");
TableElement table=new TableElement();
var tBody = table.createTBody();
var tHead=table.createTHead();
var advertisments=JSON.decode(await dataExchange.loadData("api/GetData"));
int counter=0; var head=tHead.addRow();
head.insertCell(0).text="1";
head.insertCell(1).text="2";
head.insertCell(2).text="3";
head.insertCell(3).text="4";
advertisments.forEach((item)
{
ButtonElement btn=new ButtonElement();
var line=tBody.insertRow(counter);
line.insertCell(0).text = item["data1"];
line.insertCell(1).text = item["data2"];
line.insertCell(2).text = item["data3"];
int Id=item["Id"];
btn.onClick.listen(LoadDetails(Id.toString()));
btn.text="action button";
line.insertCell(3).nodes.add(btn);
counter++; }); tableDiv.nodes.add(table); querySelector("#Content"
).setInnerHtml(tableDiv.outerHtml); } void LoadDetails(var id) { print("test
"+id); }
Have you any idea how to solve this problem?
-- 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
--
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
--
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-10-06 21:08:31 UTC
Permalink
Works.
You where right.
When i have tested your solution Harry I forgotten about reverting my
previous changes which i have made for find solution.
Thanks a lot again for You all

2016-10-06 20:38 GMT+02:00 'Harry Terkelsen' via Dart Misc <
It works for me. I wrote up your example in dartpad: https://dartpad.
dartlang.org/11d9d67caef3f15cbac49042ae5ea945
On Thu, Oct 6, 2016 at 11:36 AM Mateusz Lewandowski <
Post by Mateusz Lewandowski
I mean that functionality which i listed in my first post is in this class.
2016-10-06 20:35 GMT+02:00 Mateusz Lewandowski <
Still does not work.
Maybe the problem is that I am adding event listeners for buttons in
class instead instead in the main directly?
2016-10-06 18:23 GMT+02:00 'Harry Terkelsen' via Dart Misc <
querySelector("#Content").setInnerHtml(tableDiv.outerHtml);
You are setting the innerHtml of the '#Content' div with the outerHtml of
tableDiv. The outerHtml is just a string, it knows nothing about the actual
elements that the string represents. So you are subscribed to click events
to button elements that aren't in your html.
querySelector("#Content").children.add(tableDiv);
On Wed, Oct 5, 2016 at 3:05 PM Mateusz Lewandowski <
maybe it does not work cause of it is inside tables's cell?
2016-10-05 23:47 GMT+02:00 Mateusz Lewandowski <
When I have saved generated buttons into List<ButtonElements> and tried
click in debugger like buttons[0].click() the event was rised.
It sems that when i am clicking on button the click event is not rised
but the question is why.
2016-10-05 22:29 GMT+02:00 Mateusz Lewandowski <
Does not work, even function is not executed as in previous version when
function was executing before button click
try that
btn.onClick.listen((evt)=>LoadDetails(Id.toString()));
Hi, I have a problem with creating table with buttons inside one of the
columns.
I need to take appropriate action on click with ID parameter inside
function on click.
The problem is that on click function is executing to fast after table
load on the html page.
Future LoadData() async{
DivElement tableDiv=new DivElement();
tableDiv.classes.add("table");
TableElement table=new TableElement();
var tBody = table.createTBody();
var tHead=table.createTHead();
var advertisments=JSON.decode(await dataExchange.loadData("api/GetData"));
int counter=0; var head=tHead.addRow();
head.insertCell(0).text="1";
head.insertCell(1).text="2";
head.insertCell(2).text="3";
head.insertCell(3).text="4";
advertisments.forEach((item)
{
ButtonElement btn=new ButtonElement();
var line=tBody.insertRow(counter);
line.insertCell(0).text = item["data1"];
line.insertCell(1).text = item["data2"];
line.insertCell(2).text = item["data3"];
int Id=item["Id"];
btn.onClick.listen(LoadDetails(Id.toString()));
btn.text="action button";
line.insertCell(3).nodes.add(btn);
counter++; }); tableDiv.nodes.add(table); querySelector("#Content").
setInnerHtml(tableDiv.outerHtml); } void LoadDetails(var id) { print("test
"+id); }
Have you any idea how to solve this problem?
-- 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
--
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
--
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.
Loading...