2016-07-17 225 views
0

我想了解webix框架并将其与我的烧瓶应用程序一起使用。所有文档都处理html文件中的静态数据或php示例。使用webix与烧瓶

一个简单的HTML文件来填充数据表看起来像这样(根据 文档

<!DOCTYPE html> 
<html> 
<head lang="en"> 
    <meta charset="UTF-8"> 
    <link rel="stylesheet" href="../static/css/webix.css" type="text/css" charset="utf-8"> 
    <script src="../static/js/webix.js" type="text/javascript" charset="utf-8"></script> 
    <title>Webix Test 4</title> 
</head> 
<body> 
    <script> 
     webix.ui({ 
      id:"dtable", 
      view:"datatable", 
      url:"/gettabledata" 
     }); 
    </script> 
</body> 
</html> 

在我的烧瓶路由器我做了以下(从教程): -

peopleData = {'data':[ 
    {'title': "01. Basique", 'duration': "3:38"}, 
    {'title': "02. Moon", 'duration': "3:47"}, 
    {'title': "03. Unsaid", 'duration': "3:48"}, 
    {'title': "04. Eitheror", 'duration': "5:45"}, 
    {'title': "05. Above the Clouds", 'duration': "3:50"}]} 
return jsonify(peopleData) 

网页没有显示任何内容。

我有一个类似的问题,试图了解如何使用python加载变量(如页面标题)烧瓶。

显然,我缺少webix如何与python/flask一起工作的基础知识。 (带嵌入数据工作确定页,没有问题)

回答

1

首先你需要尝试不使用瓶

index.html

<!DOCTYPE html> 
<html> 
<head lang="en"> 
    <meta charset="UTF-8"> 
    <link rel="stylesheet" href="http://cdn.webix.com/edge/webix.css" type="text/css" charset="utf-8"> 
    <script src="http://cdn.webix.com/edge/webix.js" type="text/javascript" charset="utf-8"></script> 
    <title>Webix Test 4</title> 
</head> 
<body> 
    <script> 
webix.ui({ 
    rows: [{ 
     view: "template", 
     type: "header", 
     template: "My App!" 
     }, { 
      view: "datatable", 
      autoConfig: true, 
      editable: true, 
      data: [ 
     {'title': "01. Basique", 'duration': "3:38"}, 
     {'title': "02. Moon", 'duration': "3:47"}, 
     {'title': "03. Unsaid", 'duration': "3:48"}, 
     {'title': "04. Eitheror", 'duration': "5:45"}, 
     {'title': "05. Above the Clouds", 'duration': "3:50"}] 
     }] 
    }); 
    </script> 
</body> 
</html> 

python3 -m http.server 9004

jsfiddle

那就试试吧带烧瓶

<script> 
var my_data = webix.ajax().get("http://localhost:9004/my_route"); 
webix.ui({ 
    rows: [{ 
     view: "template", 
     type: "header", 
     template: "My App!" 
     }, { 
      view: "datatable", 
      autoConfig: true, 
      editable: true, 
      data: my_data 
     }] 
    }); 
    </script> 
+0

完美,谢谢。 – jimscafe