我知道如何做插件,但我如何做嵌套选项,如:
var defaults = {
spacing:10,
shorten_to:50,
from_start:0,
from_end:2,
classes: {
test:'testing'
}
};
Run Code Online (Sandbox Code Playgroud)
我知道这是不对的,我只是不知道如何编写正确的语法,当我想要做的事就像这样:
$('#breadcrumbs').breadcrumbs({classes{test:'new_example'},spacing:12})
Run Code Online (Sandbox Code Playgroud)
其他建议是受欢迎的,即时需要自定义类名称的能力,并且有7个,所以而不是像test_class,example_class等id那样更清洁,更整洁,就像上面的例子一样.
我通过GridFS存储文件并保存id,如下所示:
$file_id = $gridfs->storeUpload('texture');
$item = array(
'name'=>$_POST['name'],
'description'=>$_POST['description'],
'price'=>$_POST['price'],
'categories'=>$category_array,
'tags'=>$tag_array,
'file'=>$file_id
);
$collection->insert($item);
Run Code Online (Sandbox Code Playgroud)
并通过终端和find()"文件"返回:ObjectId("4cbe9afe460890b774110000")
如果我这样做是为了创建一个JSON提要,所以我可以获取信息,我的应用程序"文件"是空白的...为什么这样?:
foreach($cursor as $item){
$return[$i] = array(
'name'=>$item['name'],
'description'=>$item['description'],
'file'=>$item['file']
);
$i++;
}
echo json_encode($return);
Run Code Online (Sandbox Code Playgroud)
对我来说,奇怪的是我为什么要这样做:
foreach($cursor as $item){
echo $item['file'];
}
Run Code Online (Sandbox Code Playgroud)
并把它拿回来?
哦,这是Feed返回的内容:
[{"name":"Tea Stained Paper 1","description":"Grungy paper texture stained with tea and coffee.","file":{}},{"name":"Worn Metal 1","description":"A grooved, worn old metal texture","file":{}}]
Run Code Online (Sandbox Code Playgroud) 我不知道我做错了什么,但我有一个JSON字符串:
jsonp443489({"content":"<!DOCTYPE html><html><head><title>Title</title></head><body><p>Hello World</p></body></html>"});
Run Code Online (Sandbox Code Playgroud)
我需要解析这个以便能够修改内容.比如,例如,id想要抓住它<p>的内容.
现在,在jQuery,如果我这样做:
console.log($(json.content).html());
Run Code Online (Sandbox Code Playgroud)
它回来了Title.
如果我做:
console.log($('p',json.content));
Run Code Online (Sandbox Code Playgroud)
它返回[]一个空数组.
最后,如果我这样做:console.log($(json.content));
它回来了 [<title>?Title?</title>?,<p>?Hello World?</p>?]
这很好,但后来我无法做.find()任何事情.由于我不知道HTML会是什么,我无法使用$(json.content)[1].
有任何想法吗?
== ==更新
在黑客攻击了几个小时后,我决定尝试使用XML.我的示例XML是:
<?xml version=\"1.0\" encoding=\"UTF-8\"?><doc><item>One</item><item>Two</item></doc>
Run Code Online (Sandbox Code Playgroud)
它给了我同样的悲伤,然后它击中了我,它是一个JS对象,而不是一个字符串,jQuery期待一个字符串.我去了
$(JSON.stringify(json.content)).find('item')
Run Code Online (Sandbox Code Playgroud)
瞧!我得到了两个项目的数组.我非常兴奋但是当我再次尝试使用HTML时(使用上面的JSONP返回HTML代码段):
console.log($(JSON.stringify(json.content)).find('p'));
Run Code Online (Sandbox Code Playgroud)
我仍然得到一个空数组.这让我发疯了...还有更多想法吗?
如果有拼写错误(有set spell),它会突出显示为红色(好!),但当该行突出显示为当前行时,红色消失(坏).删除set cul修复了问题,但如何在突出显示时将单词标记为红色?我可能会在一条线上拼错多个单词,并且在输入拼写错误时也会隐藏,直到我转到下一个有点糟透人的地方.
vimrc:https:
//gist.github.com/OscarGodson/d1b05d52df4ff160b891 colorscheme:https://github.com/tomasr/molokai
通常,您应该始终将一组元素委托给父级,但很好奇是否在任何时候使用它的成本更高,或者何时真正需要它?委派 10 个处理程序真的可以节省那么多性能吗?100?1000?我应该在什么时候花时间弄清楚如何将事件委托给父视图。由于视图是独立的并且不知道父视图,因此委托并不是微不足道的,所以很好奇我在现代浏览器中获得的性能提升究竟是什么。
对于某些项目,我使用Visual Studio Code。困扰我的一件事是我无法像 Vim 的 gq 命令那样快速格式化注释块。
对于那些不了解 Vim 的人来说,gq 命令可以在您选择/突出显示一行或多行的情况下使用,如下所示:
// This is a really really long line right here
Run Code Online (Sandbox Code Playgroud)
它使它像这样
// this is a really
// really long line
// right here
Run Code Online (Sandbox Code Playgroud)
根据您的标尺设置(我的标尺设置为 80,因此它会包含任何超过 80 的单词。
我已经阅读了很多这方面的内容,但我无法弄明白.它与我的代码无关,它与feed或其他东西有关,因为如果我将它与Twitter feed交换它返回一个完美的Object对象.
$.getJSON('http://rockbottom.nozzlmedia.com:8000/api/portland/?count=1&callback=?',function(json){
console.log(json)
});
Run Code Online (Sandbox Code Playgroud)
我得到一个"无效标签"错误.有任何想法吗?
另外,旁注,我也尝试过AJAX方法:
$.ajax({
url: 'http://rockbottom.nozzlmedia.com:8000/api/portland/',
dataType: 'jsonp',
data: 'count=1',
success: function(msg){
console.log(msg)
}
});
Run Code Online (Sandbox Code Playgroud)
并且两者都给出了相同的确切错误,并且两者都适用于Flickr和Twitter示例,因此它必须与Feed有关,但我无权访问Feed,但我可以要求他们修复一些内容,如果这是他们的问题.
我实际上有两个问题,两个都可能很简单,但由于一些奇怪的原因我无法弄明白......我之前也曾使用JSON 100次!但这里是有问题的JSON:
{"69256":{
"streaminfo":{
"stream_ID":"1025",
"sourceowner_ID":"2",
"sourceowner_avatar":"http:\/\/content.nozzlmedia.com\/images\/sourceowner_avatar2.jpg",
"sourceownertype_ID":"1",
"stream_name":"Twitter",
"streamtype":"Social media"
"appsarray":[]
},
"item":{
"headline":"Charboy",
"main_image":"http:\/\/content.nozzlmedia.com\/images\/author_avatar173212.jpg",
"summary":"ate a tomato and avocado for dinner...",
"nozzl_captured":"2010-05-12 23:02:12",
"geoarray":[{
"state":"OR",
"county":"Multnomah",
"city":"Portland",
"neighborhood":"Downtown",
"zip":"97205",
"street":"462 SW 11th Ave",
"latitude":"45.5219",
"longitude":"-122.682"
}],
"full_content":"ate a tomato and avocado for dinner tonight.
such tasty foods. just enjoyable.",
"body_text":"ate a tomato and avocado for dinner tonight.
such tasty foods. just enjoyable.",
"author_name":"Charboy",
"author_avatar":"http:\/\/content.nozzlmedia.com\/images\/author_avatar173212.jpg",
"fulltext_url":"http:\/\/twitter.com\/charboy\/statuses\/13889868936",
"leftovers":{
"twitter_id":"tag:search.twitter.com,2005:13889868936",
"date":"2010-05-13T02:59:59Z",
"location":"iPhone: 45.521866,-122.682262"
},
"wordarray":{
"0":"ate",
"1":"tomato",
"2":"avocado",
"3":"dinner",
"4":"tonight",
"5":"tasty", …Run Code Online (Sandbox Code Playgroud) 这一定很简单,但我似乎无法弄明白......假设我有一个集合users,这是该集合中的第一个项目:
{
"_id" : ObjectId("4d8653c027d02a6437bc89ca"),
"name" : "Oscar Godson",
"email" : "oscargodson@xxx.com",
"password" : "xxxxxx",
"tasks" : [
{
"task" : "pick up stuff",
"comment" : "the one stuff over there"
},
{
"task" : "do more stuff",
"comment" : "lots and lots of stuff"
}
] }
Run Code Online (Sandbox Code Playgroud)
然后我将如何使用MongoDB的PHP驱动程序向集合中此项中的"tasks"数组添加另一个"任务"
在这里研究了一些问题,但它们并不能完全解决我正在寻找的问题。
假设我有一个网站并且我想要。在桌面上我想要这个:
这很容易。grid-template-columns: repeat(3, 33%)(基本上)
然而,在移动设备上,我想要这个
我遇到的情况发生在它翻转到单个列之前:
我正在尝试clamp(),minmax()以及各种各样的事情,但没有任何事情能够按照我想要的方式进行。是的,我完全可以使用媒体查询,但我希望使用现代CSS(如clamp、grid、minmax等)创建一个真正流畅的网格/柔性布局,这样就不需要媒体查询来进行基本的布局更改。
我知道这不起作用,但作为请求的起点,这是我 100 次尝试之一的简单版本:) 在这个版本中,我尝试使用钳位从重复(3)切换到重复(1)。
.wrapper {
display: grid;
gap: 15px;
grid-template-columns: repeat(clamp(1, calc(100% - 500px), 3), 33%);
}
.one {
background: red;
}
.two {
background: green;
}
.three {
background: blue;
}Run Code Online (Sandbox Code Playgroud)
<div class="wrapper">
<div class="item one"><h3>Example A</h3></div>
<div class="item two"><h3>Example Two</h3></div>
<div class="item three"><h3>Third Example</h3></div>
</div>Run Code Online (Sandbox Code Playgroud)