在动态替换内容中调用函数 [英] Calling function in dynamic replaced content

查看:68
本文介绍了在动态替换内容中调用函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




我有以下问题。在我的应用程序中,我动态地将b $ b替换为一些网页内容。例如,我有类似

的东西:


< span id =" ui_tr_22_1_treeJ_span" >

< div id =" ui_tr_22_1_treeJ">< / div>

< script type =" text / javascript">


功能乐趣(){


雅虎树正在生成....


}

< / script>

< input type =''text''onclick =" fun()">< / input>

< / span>


这个范围由DWR替换为另一个具有不同乐趣的
函数。我的问题是,在更改之后,当我确定DOM

被正确更新时,它被称为有趣功能的原始版本。


预先感谢任何线索。


问候,


彼得

Hi,

I have the following problem. In my application I''m dynamically
replacing some of web-page content. For example, I have something like
that:

<span id="ui_tr_22_1_treeJ_span" >
<div id="ui_tr_22_1_treeJ"></div>
<script type="text/javascript">

function fun (){

Yahoo tree is generating....

}
</script>
<input type=''text'' onclick="fun()"></input>
</span>

This span is replaced by DWR to another which has different body of fun
function. My problem is that after the change, when I''m sure that DOM
was properly updated, it''s called an original version of fun function.

Thanks in advance for any clues.

Regards,

Peter

推荐答案

deepres在11/23/2006上午9:24发表以下内容:
deepres said the following on 11/23/2006 9:24 AM:




我有以下问题。在我的应用程序中,我动态地将b $ b替换为一些网页内容。例如,我有类似

的东西:
Hi,

I have the following problem. In my application I''m dynamically
replacing some of web-page content. For example, I have something like
that:



哪个是无效的HTML。

Which is invalid HTML.


< span id =" ui_tr_22_1_treeJ_span" >

< div id =" ui_tr_22_1_treeJ">< / div>

< script type =" text / javascript">


功能乐趣(){


雅虎树正在生成....


}

< / script>

< input type =''text''onclick =" fun()">< / input>

< / span>


这个范围由DWR替换为另一个具有不同乐趣的
函数。
<span id="ui_tr_22_1_treeJ_span" >
<div id="ui_tr_22_1_treeJ"></div>
<script type="text/javascript">

function fun (){

Yahoo tree is generating....

}
</script>
<input type=''text'' onclick="fun()"></input>
</span>

This span is replaced by DWR to another which has different body of fun
function.



" DWR"?

"DWR"?


我的问题是在改变之后,当我在确保DOM

已正确更新,它被称为有趣功能的原始版本。
My problem is that after the change, when I''m sure that DOM
was properly updated, it''s called an original version of fun function.



演示问题的示例测试页?但是,它可能会导致您使用innerHTML替换它并且

脚本块没有更新。


< URL:

http://groups-beta.google.com/group/comp.lang.javascript/browse_frm/thread/fb360f782ef616ad/26af58522a10514d?lnk=gst& ; q = randy + webb + loadjsfile + g etElementsByTagName& rnum = 1#26af58522a10514d>


帖子中的最后一条消息。


- -

兰迪

机会有利于准备好的心灵

comp.lang.javascript常见问题 - http://jibbering.com/faq

Javascript最佳实践 - http://www.JavascriptToolbox.com/bestpractices/




Randy Webb napisal(a):

Randy Webb napisal(a):

deepres在11/23/200上说以下内容6 9:24 AM:
deepres said the following on 11/23/2006 9:24 AM:




我有以下问题。在我的应用程序中,我动态地将b $ b替换为一些网页内容。例如,我有类似

的东西:
Hi,

I have the following problem. In my application I''m dynamically
replacing some of web-page content. For example, I have something like
that:



哪个是无效的HTML。


Which is invalid HTML.



就本例而言,我缩短了趣味功能的内容。

Just for this example i''ve shortened the content of fun function.


>
>

< span id =" ui_tr_22_1_treeJ_span" >

< div id =" ui_tr_22_1_treeJ">< / div>

< script type =" text / javascript">


功能乐趣(){


雅虎树正在生成....


}

< / script>

< input type =''text''onclick =" fun()">< / input>

< / span>


这个范围由DWR替换为另一个具有不同乐趣的
函数。
<span id="ui_tr_22_1_treeJ_span" >
<div id="ui_tr_22_1_treeJ"></div>
<script type="text/javascript">

function fun (){

Yahoo tree is generating....

}
</script>
<input type=''text'' onclick="fun()"></input>
</span>

This span is replaced by DWR to another which has different body of fun
function.



" DWR"?


"DWR"?



AJAX包装器

AJAX wrapper


>
>

我的问题是,在更改之后,当我确定DOM

被正确更新时,它被称为有趣功能的原始版本。
My problem is that after the change, when I''m sure that DOM
was properly updated, it''s called an original version of fun function.



演示问题的示例测试页?但是,它可能会导致您使用innerHTML替换它并且

脚本块未更新。


Sample test page that demonstrates the problem? But, it is probably
going to lead to the fact that you are replacing it using innerHTML and
the script block isn''t getting updated.



的确,这就是我将树生成块放入

函数体的原因,以便能够手动定义它。不幸的是,它的原始状态是保守的。

Indeed, that was the reason that i put the tree generation block into a
body of function, to be able to ivoke it manually. Unfortunately, its
original state is conserved.


>

< URL:

http://groups-beta.google.com/group/comp.lang.javascript/browse_frm/thread/fb360f782ef616ad/26af58522a10514d?lnk=gst&q=randy+webb+loadjsfile+g etElementsByTagName& rnum = 1 #26af58522a10514d>


线程中的最后一条消息。
>
<URL:
http://groups-beta.google.com/group/comp.lang.javascript/browse_frm/thread/fb360f782ef616ad/26af58522a10514d?lnk=gst&q=randy+webb+loadjsfile+g etElementsByTagName&rnum=1#26af58522a10514d>

Very last message in the thread.



谢谢你:)

Thanks for that :)


>

-

兰迪

机会有利于准备好的心灵

comp.lang.javascript常见问题 - http://jibbering.com/faq

Javascript最佳实践 - http://www.JavascriptToolbox.com/bestpractices/



Peter

Peter


deepres在2006年11月24日凌晨3:42发表以下内容:
deepres said the following on 11/24/2006 3:42 AM:

Randy Webb napisal(a ):
Randy Webb napisal(a):

> deepres在2006年11月23日上午9:24说以下内容:
>deepres said the following on 11/23/2006 9:24 AM:

>>

我有以下问题。在我的应用程序中,我动态地替换了一些网页内容。例如,我有类似
的内容:
>>Hi,

I have the following problem. In my application I''m dynamically
replacing some of web-page content. For example, I have something like
that:


哪个是无效的HTML。

Which is invalid HTML.



就本例而言,我缩短了趣味功能的内容。

Just for this example i''ve shortened the content of fun function.



fun函数的内容与无效HTML无关。

The content of fun function had nothing to do with it being invalid HTML.


>>我的问题是,在更改之后,当我确定DOM
已正确更新时,它被称为有趣功能的原始版本。
>> My problem is that after the change, when I''m sure that DOM
was properly updated, it''s called an original version of fun function.


演示问题的示例测试页?但是,它可能会导致你使用innerHTML替换它并且脚本块没有得到更新。

Sample test page that demonstrates the problem? But, it is probably
going to lead to the fact that you are replacing it using innerHTML and
the script block isn''t getting updated.



的确,这就是我将树生成块放入

函数体中的原因,以便能够手动将其调用。不幸的是,它的原始状态是保守的。


Indeed, that was the reason that i put the tree generation block into a
body of function, to be able to ivoke it manually. Unfortunately, its
original state is conserved.



因为当你通过innerHTML替换它时它不会被执行。


-

Randy

机会有利于准备好的心灵

comp.lang.javascript常见问题 - http://jibbering.com/faq

Javascript最佳实践 - http://www.JavascriptToolbox.com/bestpractices/


这篇关于在动态替换内容中调用函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆