开发者

JavaScript, load component/call method only if needed

I am searching for a way to clean my HTML views from script-tags.

Example:

(A view with a script tag)

<script type="text/javascript">
    $jQ开发者_运维百科uery().ready(function() {
        call.a.method();
    }
</script>

I would like to remove this script tag and put it into a class - this class should initizalize on the document ready event and execute the method which belongs to the called view.

How could I realize something like that? Is there some best practice?

Short version of my intention: 1.) Remove script tags from html files and put this code into some methods/functions 2.) Only call the method/function that belongs to a view if I call the view: Example: www.url.com/testview.html Execute: obj.views.testview();

How could I realize something like a mapping and is it possible to identify the called file/view?


must move it in to a script file :)

something.js

JS Code:

$jQuery().ready(function() {
        call.a.method();
    }

html code

<script src="scripts/jquery-1.6.1.min.js" type="text/javascript" charset="utf-8"></script>
<script src="scripts/something.js" type="text/javascript" charset="utf-8"></script>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜