我正在使用五角星创建这个评级系统.我希望标题包括平均评级.所以我创造了显示1/5的星星.使用"1.2"我将获得一颗满星并在下一颗恒星上获得一分等等......
但是我还没有找到一个很好的方法来收集到最接近的.2 ...我想我可以乘以10,然后是一轮,然后转到第1轮到第2轮,第3轮到第4轮等等.上.但这似乎乏味且不必要......
我刚刚开始使用dojo,我已经明白这dojo.query和$jQuery一样了.
但我还没弄清楚它的回归.它是jQuery中的专用对象吗?
我想做的事(没有运气)是:
dojo.query("output").innerHTML = data;
//this doesn't work either:
dojo.query("output").html(data);
//tried accessing by id as well
dojo.query("#output").html(data);
//and tried to access a div, incase dojo has some issues with html5 elements
dojo.query("#divOutput").html(data);
Run Code Online (Sandbox Code Playgroud)
我目前正在使用新的html5元素:
<output id="output">Output goes here</output>
<div id="divOutput">non-html5 output goes here</div>
Run Code Online (Sandbox Code Playgroud)
我似乎无法找到一个关于如何处理返回的对象的好列表dojo.query()..
编辑:好的,我觉得道场现在只是搞砸了我.我找到了这个方法:addContent()并且适用于上面的选择器.但我不想添加内容,我想替换内容......
从dojo文档开始dijit.registry,我看到该forEach方法接受最后一个参数thisObject.但它不是那个对象的方式.它是一个dijit小部件还是一个dojo对象?
我想破坏(将由AJAX被替换的元素)内的所有部件,使他们能够再次没有冲突的ID的解析.
dijit.registry.forEach(function(w) {
w.destroyRecursive();
}, dojo.byId("ajaxElement"));
Run Code Online (Sandbox Code Playgroud)
但这会破坏网页上的所有小部件......
我有以下HTML和CSS:
<button id="myBtn" dojoType="dijit.form.Button">Testing</button>
#myBtn {
margin-left: 100px;
}
Run Code Online (Sandbox Code Playgroud)
CSS应该按下按钮100px.但是,由于dijit在按钮周围应用了一些额外的HTML层,按钮会获得100px填充.
编辑:找到一个(不是IE6兼容)解决方案:
[widgetid=myBtn] { margin-left: 100px; }
Run Code Online (Sandbox Code Playgroud) 我试图知道DOM中点击的元素与某个其他元素的距离是多远.
<li>item1</li>
<li>item2</li>
<li class="active">item3</li>
<li>item4</li>
<li>item5</li>
<li>item6</li>
<li>item7</li>
Run Code Online (Sandbox Code Playgroud)
因此,当用户点击一个元素,应该在距离恢复到有源元件:那么item1: return -2,item4: return 1,item6: return 3,等等.
我目前正在开发两个应用程序App1,即将文件从Dropbox下载到iPad,以及App2.Dropbox集成有点麻烦,我宁愿不在两个应用程序上都这样做.那么可以从可能访问它们的App1某个地方保存这些文件App2吗?我听说应用程序的沙盒在iOS6中有点宽松,但不确定多么宽松.
我在这里看到了一些类似的问题,但它们似乎是通过使用URL方案或将数据发送到其他应用程序来解决的,这不是我真正想要的.
任何其他想法来解决这个问题将不胜感激.
我正在使用新的.NET Web API设置休息服务,我遇到了一个小问题.我们希望有一个不同的路由,但我不知道如何实现这一点.
public class FormController : ApiController
{
// api/form
public string Get()
{
return "OK-Get";
}
// api/form/method1
public string Method1()
{
return "OK1";
}
// api/form/method2
public string Method2()
{
return "OK2";
}
}
Run Code Online (Sandbox Code Playgroud)
但这不起作用.如果我去/api/form/method2,我得到OK-Get回应.
我认为这与路由有关,但我不确定,因为我之前没有使用过MVC.我尝试过这样设置WebApiConfig.cs:
config.Routes.MapHttpRoute(
name: "FormApi",
routeTemplate: "api/form/{action}"
);
Run Code Online (Sandbox Code Playgroud)
但那没有做任何事.
我正在使用具有可拖动滚动条的图像查看器.当用户拖动滚动条时,网页上的某些文本会被选中.我试过了
window.getSelection().removeAllRanges();
Run Code Online (Sandbox Code Playgroud)
但这似乎不适用于IE7/8.也试过了
document.getSelection().removeAllRanges();
Run Code Online (Sandbox Code Playgroud)
这似乎与IE7/8一样"好".
有没有其他方法可以做到这一点?不知道任何jQuery解决方案,但如果有,请告诉我(:
编辑:这是onmouse事件的上下文
$("#slideBar").mousedown(function(f) {
mouseDown = true;
some more code...
}
$(document).mouseup(function() {
if (mouseDown) {
window.getSelection().removeAllRanges();
more code...
}
}
Run Code Online (Sandbox Code Playgroud) 是否有一种扩展/关闭所有可扩展节点的好方法dijit.Tree?
对于那些寻找答案的人,请将其放入初始化代码中:
var treeControl = new dijit.Tree({
model: treeModel,
expandAll: function() {
// summary:
// Expand all nodes in the tree
// returns:
// Deferred that fires when all nodes have expanded
var _this = this;
function expand(node) {
_this._expandNode(node);
var childBranches = dojo.filter(node.getChildren() || [], function(node) {
return node.isExpandable;
});
var def = new dojo.Deferred();
defs = dojo.map(childBranches, expand);
}
return expand(this.rootNode);
}
});
Run Code Online (Sandbox Code Playgroud)
至少,这对我有用.你也可以做同样的collapseAll(),你只需要切换_this._expandNode(node);与_this._collapseNode(node);