Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/jquery-ui/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 应用jquerymobile';s风格发挥作用_Javascript_Jquery Ui_D3.js - Fatal编程技术网

Javascript 应用jquerymobile';s风格发挥作用

Javascript 应用jquerymobile';s风格发挥作用,javascript,jquery-ui,d3.js,Javascript,Jquery Ui,D3.js,我有一个D3函数,可以在页面上创建列表项。我想让jQueryUIMobile为它们设置样式,但当我以多种方式调用函数时,它们永远不会设置样式 D3/JS: var sampdata = [{itemname: "Placeholder0", numvalue: "$000,000"}, {itemname: "Placeholder1", numvalue: "$543,600"}, {itemname: "Placeholder2", numvalue: "$9,200"},

我有一个D3函数,可以在页面上创建列表项。我想让jQueryUIMobile为它们设置样式,但当我以多种方式调用函数时,它们永远不会设置样式

D3/JS:

var sampdata = [{itemname: "Placeholder0", numvalue: "$000,000"},
    {itemname: "Placeholder1", numvalue: "$543,600"},
    {itemname: "Placeholder2", numvalue: "$9,200"},
    {itemname: "Placeholder3", numvalue: "$5,100"}];

setupgui: function()
    {
        d3.select("#SampcoISrevenues").selectAll("li")
                .data(sampdata)
                .enter()
                .append("li")
                .text(function (d){return d.itemname;})
                .append("span")
                .attr("class", "right")
                .text(function (d){return d.numvalue;});
    }
其中,此函数选择屏幕保留的部分,然后从“sampdata”中添加列表项。 HTML:


我按照以下顺序引用D3库、my index.js和JQuery(JQmobile.css/.js、JQ.js):

    <link rel="stylesheet" href="../../css/jquery.mobile-1.4.2.css">
    <link rel="stylesheet" href="../../css/index.css">
    <script src="../../js/jquery-1.11.1.js"></script>
    <script src="../../js/jquery.mobile-1.4.2.js"></script>
    <script src="../../js/d3.js"></script>
    <script src="../../js/yourdata.js"></script>

虽然D3函数可以立即运行,但jquerymobile不会对其进行样式化。我希望它的风格,因为它非常适合移动设备。

根据:

更新列表

如果向listview添加项目,则需要对其调用
refresh()
方法来更新样式并创建添加的任何嵌套列表


更新d3代码中的列表后,尝试调用
$('#sampcois').listview('refresh')

您可以使用JQuery的.ready()运行函数:

$(document).ready(Samplegui.setupgui())

这就是我尝试的,但问题是我在加载实际HTML代码之前运行了D3函数,因此D3无法找到正确的ID/标记。粘住

   `<script>
        $(document).ready(Samplegui.setupgui());
    </script>`
`
$(document.ready(Samplegui.setupgui());
`

在页面底部解决了这个问题。

这可能是在d3运行之前没有加载jquery文件的问题。ul是否使用jquery代码?
   `<script>
        $(document).ready(Samplegui.setupgui());
    </script>`