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
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 g**********y
发帖数: 14569
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
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
I want to dynamically generate
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.
发帖数: 1879
2
The reason the second part is not working is because this piece ofcode 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
: 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.
发帖数: 345
3
Dojo or YUI's event package may hide the details from you发帖数: 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.
发帖数: 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