我从头开始尝试使用良好的实践,从头开始了一个dojo项目.我是dojo工具包的新手,所以我正在浏览大量的文档和示例,这给我留下了很多很酷的东西,但没有办法为未来的dev(或附加组件)实现架构.我在网上搜索过,发现这个dojo样板项目似乎是一个很好的开始,但是我想要更多东西,我想实现MVC模式(我有很多经验,有关JAVA和Ruby on rails dev )在我的应用程序中,遇到了这个非常酷的例子.所以,我创建了这样的东西,这似乎是组织我的项目非常合法的方式.纠正我,如果我错了......或者你有更好的方法.
现在,我准备开始了.我在dojo toolkit网站上尝试了几个教程.当你只有一个页面时,运行得非常好.但是现在,我想知道如何将这个布局教程实现到我自己的应用程序中.我希望这种布局成为我的应用程序的主要布局(所以,我试着把这些代码片段放到我的index.html中),
<div
id="appLayout" class="demoLayout"
data-dojo-type="dijit.layout.BorderContainer"
data-dojo-props="design: 'headline'">
<div
class="centerPanel"
data-dojo-type="dijit.layout.ContentPane"
data-dojo-props="region: 'center'">
<div>
<h4>Group 1 Content</h4>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. …
Run Code Online (Sandbox Code Playgroud) <div class="container-fluid">
<div class="sidebar left">
<div id="app-navigation" class="well">
<h5>Administration</h5>
<ul class="administration-list">
<li class="user"><a href="#user">User</a></li>
<li class="emails"><a href="#emails">Emails</a></li>
<li class="settings"><a href="#Settings">Settings</a></li>
<li class="logs"><a href="#Logs">Logs</a></li>
<li class="help"><a href="#Help">Help</a></li>
</ul>
<h5>Managing tools</h5>
<ul class="tools-list">
<li class="ressource"><a href="#Ressources"><i class="icon-home icon-white" </i>Ressources</a></li>
<li class="playlist"><a href="#Playlist">Playlist</a></li>
<li class="schedule"><a href="#Schedule">Schedule</a></li>
<li class="stations"><a href="#Stations">Stations</a></li>
</ul>
</div>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
我不明白为什么我的图标没有出现.我正在开始一个新项目,并决定尝试 使用bootstrap 初始化.只是不能让那些图标出现.在我的文本之前似乎有一个看不见的图标......我也在这里查看文档.我还检查了我的boostrap.less,sprites.less和variables.less(一切似乎没问题......).
我的变量设置正确,我的图像(PNG)位于我的../img文件夹中.
// Sprite icons path
// -------------------------
@iconSpritePath: "../img/glyphicons-halflings.png";
@iconWhiteSpritePath: "../img/glyphicons-halflings-white.png";
Run Code Online (Sandbox Code Playgroud) 在Android中使用Rest Framework处理json有什么好的做法.例如,如果我得到一个特定的json结果如下(或任何其他,我只是给一些更复杂的东西):
{"lifts":
[{
"id":26,
"time":"2012-11-21T12:00:00Z",
"capacity":4,
"price":10,
"from": {
"description":null,
"city": {
"name":"Montreal"
}
},
"to":{
"description":"24 rue de la ville",
"city":{
"name":"Sherbrooke"
}
},
"driver":{
"first_name": "Benjamin",
"image":"https://graph.facebook.com/693607843/picture?type=large"
}
}
]}
Run Code Online (Sandbox Code Playgroud)
1)我应该手动处理结果并获取每个值来填充我的ui ...(不是真的)
2)我应该为每个对象创建一个POJO(使用JSONObject处理映射).在我的例子中,我将不得不创建一个处理所有参数的提升对象,甚至创建更多的POJO,以用于例如图像和可能的位置.(所以基本上,我经常需要检查我的api休息框架,看看我的对象是如何在服务器端完成的,我正在将我的模型从服务器复制到android客户端).
3)是否有任何框架来处理映射(序列化和反序列化).
我目前正在使用2号选项,但想知道那里是否有更好的东西.到目前为止,它对我有用,用于接收和发送.
有没有关于如何实现简单登录页面/对话框的示例?我一直在尝试使用dojo样板(检查我之前的问题:Dojo MVC的布局实现).到目前为止,我已经能够显示我的对话框.但我希望能够获取我的数据和点击事件想要一个警告框(例如他的内容).
我的看法:
<form action="Login" method="post" validate="true" id="loginForm">
<table width="258">
<tr>
<td><label>Login</label></td>
<td><input class="cell" type="text" trim="true" dojoType="dijit.form.TextBox" value="" name="login" id="userId"/></td>
</tr>
<tr>
<td><label>Password</label></td>
<td><input class="cell" type="password" trim="true" dojoType="dijit.form.TextBox" value="" name="password" id="password"/></td>
</tr>
<tr><td colspan="2"> </td></tr>
<tr>
<td colspan="2" align="center">
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td align="center" valign="top"><button dojoType="dijit.form.Button" type="submit" id="LoginButton" onClick="connect">Ok</button></td>
<td align="left" valign="top"><button dojoType="dijit.form.Button" type="submit" onclick="document.Login.reset()" id="Cancel">Cancel</button></td>
<td><button dojoType="dijit.form.Button" type="submit" onclick="showDialog();" id="resetPassword"> Show Dialog </button></td>
</tr>
</table>
</td>
</tr>
</table>
</form>
Run Code Online (Sandbox Code Playgroud)
我的Widget模块/类
define([
"dojo/_base/declare", …
Run Code Online (Sandbox Code Playgroud) 我来到了一个带有dojo 1.5的示例应用程序,但它并不是我想要实现的:它根本不是模块化的.我想利用amd和各种设计模式(如MVC)来组织一个非常有组织的应用程序.不幸的是,dojo社区和"示例"不是很明显或存在(与Jquery相比).关于特定dojo功能的各种实现有很多很酷的教程,但没有一个解释了如何为dojo项目创建一个简单(但同时也很复杂)的squeleton.我在github上遇到了dojo样板项目,并尝试从那里开始,但我发现实现诸如登录或基本接口之类的琐碎事情(作为初学者)真的很难(并且通过模块分离所有这些,事件处理,数据等).我只是不想通过仅使用index.html和一个javascript文件来创建dojo应用程序,我可以做到,但是为了维护和添加内容,它只是一个完整的混乱.在这篇文章中,我希望获得有关此特定主题的一些信息,并可能为dojo创建一个关于如何启动真实Web应用程序的教程.例如,应用mvc模式,我认为一个好的应用程序教程应该有一个登录示例(authentification)和一个基本的模块化接口(就像某种主要容器,并且在各种事件上,容器ui例如用不同的widget更改) .我将在github上做一些事情,并在我完成后发布.如果你在继续之前完成;)
谢谢.
我已经基于这个示例应用程序启动了一个jquery/backbone.js应用程序并对其进行了相当大的修改以完成我自己的工作,但MVC概念仍然存在.到目前为止,一切正常,我基本上只是添加我的内容/模型/等.当我需要的时候.
我需要实现一个基本的文件上传器,并发现这个JQuery文件上传很棒(我不想重新发明轮子......因为,我在"赶时间").有没有人以前做过这个?到目前为止,我已经下载了zip文件并在WampServer(PHP)上运行,它运行得很好(我阅读了安装手册).如何在应用程序中使用/附加它(使用小部件)?你是怎么做的(我对插件没有太多经验)
代码部分:
tpl/ResourcesView.html(所以如果我们只从演示中获取有趣的部分):
<div class="content fixed-fixed">
<!-- The file upload form used as target for the file upload widget -->
<form id="fileupload" action="plugin/jquery-fileupload/server/php/" method="POST" enctype="multipart/form-data">
<!-- The fileupload-buttonbar contains buttons to add/delete files and start/cancel the upload -->
<div class="row fileupload-buttonbar">
<div class="span7">
<!-- The fileinput-button span is used to style the file input field as button -->
<span class="btn btn-success fileinput-button">
<i class="icon-plus icon-white"></i>
<span>Add files...</span>
<input type="file" name="files[]" multiple> …
Run Code Online (Sandbox Code Playgroud) 好吧,我已经能够使它与DataGrid一起工作,但由于某种原因,Dgrid可能真的令人印象深刻,同时,真的很令人沮丧(许多人推荐它).到目前为止,我已经能够请求一定数量的数据(只有第一次调用,所以我的请求标头指定返回25项...),一旦我尝试向下滚动以获得更多项目(因此应该发送额外的请求) 什么都没发生.
基本上这是用jsonrest构建的商店:
define([
"dojo/store/Memory",
"dojo/store/JsonRest",
"dojo/store/Cache",
"dojo/store/Observable"
],
function(
Memory,
JsonRest,
Cache,
Observable
){
var contentMemoryStore = new Memory();
var contentJsonRestStore = new JsonRest({target: "http://dev.mpact.tv:30087/rest/contenus/"});
contentStore = new Cache(contentJsonRestStore, contentMemoryStore);
return new Observable(contentStore);
});
Run Code Online (Sandbox Code Playgroud)
然后,我将此商店传递给OnDemandGrid的属性.
我检查了这个人的例子:http://www.speich.net/articles/demos/jsonrest/dojo-demo-dgrid.php 我检查了dgrid(OnDemandList)的文档:https://github.com/SitePen/dgrid /维基/核心组件
添加了Request标头/ Response标头(但我认为它们是正确的):
服务器端代码(在perl中):
$r->headers_out->set('Content-Range', sprintf("items %d-%d/%d", $start, $start
+ $num_items - 1, $total));
Run Code Online (Sandbox Code Playgroud)
更新:
我用旧的jsonstore(dojox/data)进行了快速测试:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Statut des canaux générés par Gipsy</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"></meta> …
Run Code Online (Sandbox Code Playgroud) dojo ×4
javascript ×3
android ×1
asp.net-mvc ×1
backbone.js ×1
css ×1
dgrid ×1
html ×1
jquery ×1
json ×1
layout ×1
less ×1
pojo ×1