Redian新闻
>
AJAX: simple question on parameter passing
avatar
AJAX: simple question on parameter passing# Java - 爪哇娇娃
g*y
1
[Purpose]
I want to dynamically generate with onmouseover event. And I want to
pass a String rowClass to that event function.
[Working code]
tr.onmouseover = new Function("this.className = '" + rowClass + "';");
[Not-working code]
tr.onmouseover = function() { this.className = rowClass; }
[Question]
I prefer the coding style of [Not-working code], any way to make it work?
Thanks for suggestion.c*****t
发帖数: 1879
2
The reason the second part is not working is because this piece of
code is embeded as part of DOM, which doesn't understand JavaScript.
The code is evaluated by JS engine after mouse over.
The second method has memory leak problem anyways, so it doesn't matter.

【在 g**********y 的大作中提到】
: [Purpose]
: I want to dynamically generate with onmouseover event. And I want to
: pass a String rowClass to that event function.
: [Working code]
: tr.onmouseover = new Function("this.className = '" + rowClass + "';");
: [Not-working code]
: tr.onmouseover = function() { this.className = rowClass; }
: [Question]
: I prefer the coding style of [Not-working code], any way to make it work?
: Thanks for suggestion.
f*******4
发帖数: 345
3
Dojo or YUI's event package may hide the details from you
g**********y
发帖数: 14569
4
So you mean the second format is not well supported (in memory-leak sense),
and first one is more preferrable?
What a pity! Second one is more clear and easy to read as a function. I hate
to read first one, it's like read/maintain HTML from a servlet.
BTW, mitbbs.com interface really amazed me: in one week, I've already saw 3
or 4 "families" of UI when I come to this site. What's going on???
a) They are demonstrating Abstract-Factory pattern
b) They are showing power of Interface programming
c)

【在 c*****t 的大作中提到】
: The reason the second part is not working is because this piece of
: code is embeded as part of DOM, which doesn't understand JavaScript.
: The code is evaluated by JS engine after mouse over.
: The second method has memory leak problem anyways, so it doesn't matter.

g**********y
发帖数: 14569
5
Thanks for recommendation. I will try both.
BTW, I just go to dojo wite: can't judge the quality of their code, but
their website absolutely sucks. I spend 5 minutes trying to be educated, end
up with: not complete, visit another page, come back again, ... it's an
excellent example of how to compell potential user :-)

【在 f*******4 的大作中提到】
: Dojo or YUI's event package may hide the details from you
avatar
c*t
2
The reason the second part is not working is because this piece of
code is embeded as part of DOM, which doesn't understand JavaScript.
The code is evaluated by JS engine after mouse over.
The second method has memory leak problem anyways, so it doesn't matter.

【在 g**********y 的大作中提到】
: [Purpose]
: I want to dynamically generate with onmouseover event. And I want to
: pass a String rowClass to that event function.
: [Working code]
: tr.onmouseover = new Function("this.className = '" + rowClass + "';");
: [Not-working code]
: tr.onmouseover = function() { this.className = rowClass; }
: [Question]
: I prefer the coding style of [Not-working code], any way to make it work?
: Thanks for suggestion.
f*******4
发帖数: 345
3
Dojo or YUI's event package may hide the details from you
g**********y
发帖数: 14569
4
So you mean the second format is not well supported (in memory-leak sense),
and first one is more preferrable?
What a pity! Second one is more clear and easy to read as a function. I hate
to read first one, it's like read/maintain HTML from a servlet.
BTW, mitbbs.com interface really amazed me: in one week, I've already saw 3
or 4 "families" of UI when I come to this site. What's going on???
a) They are demonstrating Abstract-Factory pattern
b) They are showing power of Interface programming
c)

【在 c*****t 的大作中提到】
: The reason the second part is not working is because this piece of
: code is embeded as part of DOM, which doesn't understand JavaScript.
: The code is evaluated by JS engine after mouse over.
: The second method has memory leak problem anyways, so it doesn't matter.

g**********y
发帖数: 14569
5
Thanks for recommendation. I will try both.
BTW, I just go to dojo wite: can't judge the quality of their code, but
their website absolutely sucks. I spend 5 minutes trying to be educated, end
up with: not complete, visit another page, come back again, ... it's an
excellent example of how to compell potential user :-)

【在 f*******4 的大作中提到】
: Dojo or YUI's event package may hide the details from you
avatar
f*4
3
Dojo or YUI's event package may hide the details from you
avatar
g*y
4
So you mean the second format is not well supported (in memory-leak sense),
and first one is more preferrable?
What a pity! Second one is more clear and easy to read as a function. I hate
to read first one, it's like read/maintain HTML from a servlet.
BTW, mitbbs.com interface really amazed me: in one week, I've already saw 3
or 4 "families" of UI when I come to this site. What's going on???
a) They are demonstrating Abstract-Factory pattern
b) They are showing power of Interface programming
c)

【在 c*****t 的大作中提到】
: The reason the second part is not working is because this piece of
: code is embeded as part of DOM, which doesn't understand JavaScript.
: The code is evaluated by JS engine after mouse over.
: The second method has memory leak problem anyways, so it doesn't matter.

avatar
g*y
5
Thanks for recommendation. I will try both.
BTW, I just go to dojo wite: can't judge the quality of their code, but
their website absolutely sucks. I spend 5 minutes trying to be educated, end
up with: not complete, visit another page, come back again, ... it's an
excellent example of how to compell potential user :-)

【在 f*******4 的大作中提到】
: Dojo or YUI's event package may hide the details from you
相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。