dojo 自动填充示例不起作用

发布于 2024-11-09 10:10:53 字数 2081 浏览 0 评论 0原文

我从道场网站上得到了这个例子。但这对我不起作用。

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">

<head>
    <style type="text/css">
        body, html { font-family:helvetica,arial,sans-serif; font-size:90%; }
    </style>
    <script src="http://ajax.googleapis.com/ajax/libs/dojo/1.6/dojo/dojo.xd.js"
    djConfig="parseOnLoad: true">
    </script>
    <script type="text/javascript">
        dojo.require("dijit.form.FilteringSelect");
        dojo.require("dojo.data.ItemFileReadStore");
    </script>
    <script type="text/javascript">
        dojo.addOnLoad(function() {
            var stateStore = new dojo.data.ItemFileReadStore({
                url: "../../_static/js//dijit/tests/_data/states.json"
            });
            var filteringSelect = new dijit.form.FilteringSelect({
                id: "stateSelect",
                name: "state",
                value: "KY",
                store: stateStore,
                searchAttr: "name"
            },
            "stateSelect");
        });
    </script>
    <link rel="stylesheet" type="text/css" href="http://ajax.googleapis.com/ajax/libs/dojo/1.6/dijit/themes/claro/claro.css"
    />
</head>

<body class=" claro ">
    <input id="stateSelect">
    <p>
        <button onClick="alert(dijit.byId('stateSelect').get('value'))">
            Get value
        </button>
        <button onClick="alert(dijit.byId('stateSelect').get('displayedValue'))">
            Get displayed value
        </button>
    </p>
    <!-- NOTE: the following script tag is not intended for usage in real
    world!! it is part of the CodeGlass and you should just remove it when
    you use the code -->
    <script type="text/javascript">
        dojo.addOnLoad(function() {
            if (document.pub) {
                document.pub();
            }
        });
    </script>
</body>

I have got this example from the dojo site. However this is not working for me.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">

<head>
    <style type="text/css">
        body, html { font-family:helvetica,arial,sans-serif; font-size:90%; }
    </style>
    <script src="http://ajax.googleapis.com/ajax/libs/dojo/1.6/dojo/dojo.xd.js"
    djConfig="parseOnLoad: true">
    </script>
    <script type="text/javascript">
        dojo.require("dijit.form.FilteringSelect");
        dojo.require("dojo.data.ItemFileReadStore");
    </script>
    <script type="text/javascript">
        dojo.addOnLoad(function() {
            var stateStore = new dojo.data.ItemFileReadStore({
                url: "../../_static/js//dijit/tests/_data/states.json"
            });
            var filteringSelect = new dijit.form.FilteringSelect({
                id: "stateSelect",
                name: "state",
                value: "KY",
                store: stateStore,
                searchAttr: "name"
            },
            "stateSelect");
        });
    </script>
    <link rel="stylesheet" type="text/css" href="http://ajax.googleapis.com/ajax/libs/dojo/1.6/dijit/themes/claro/claro.css"
    />
</head>

<body class=" claro ">
    <input id="stateSelect">
    <p>
        <button onClick="alert(dijit.byId('stateSelect').get('value'))">
            Get value
        </button>
        <button onClick="alert(dijit.byId('stateSelect').get('displayedValue'))">
            Get displayed value
        </button>
    </p>
    <!-- NOTE: the following script tag is not intended for usage in real
    world!! it is part of the CodeGlass and you should just remove it when
    you use the code -->
    <script type="text/javascript">
        dojo.addOnLoad(function() {
            if (document.pub) {
                document.pub();
            }
        });
    </script>
</body>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

2024-11-16 10:10:53

首先,您应该删除此代码:

 <!-- NOTE: the following script tag is not intended for usage in real
    world!! it is part of the CodeGlass and you should just remove it when
    you use the code -->
    <script type="text/javascript">
        dojo.addOnLoad(function() {
            if (document.pub) {
                document.pub();
            }
        });
    </script>

第二个问题是填充 ItemFileReadStore。您的网站上真的有这个文件 "../../_static/js//dijit/tests/_data/states.json" 吗?如果没有,您应该创建它(或修复文件路径)或使用其他方法来填充 ItemFileReadStore。

First of all you should remove this code:

 <!-- NOTE: the following script tag is not intended for usage in real
    world!! it is part of the CodeGlass and you should just remove it when
    you use the code -->
    <script type="text/javascript">
        dojo.addOnLoad(function() {
            if (document.pub) {
                document.pub();
            }
        });
    </script>

And the second problem is populating ItemFileReadStore. Do you really have this file "../../_static/js//dijit/tests/_data/states.json" on your site ? If no, you should create it(or fix file path) or use another method to populate ItemFileReadStore.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文