我正在寻找使用ajax排序前端列表的最佳实践.
所以我有一个循环遍历所有项目的组件.然后是带有复选框的侧边栏,使用Ajax进行过滤.每个复选框都是一个类别,并通过检查该过滤器进行过滤.
在我的组件default.htm我有
{% set items = __SELF__.items %}
<div class="col-md-12" id="results">
{% for item in items %}
<ul>
<li>{{ item.title }} - {{ item.description }}</li>
</ul>
{% endfor %}
</div>
Run Code Online (Sandbox Code Playgroud)
和一个按钮,直到我让它切换到复选框.
<button class="btn btn-default"
data-request="onHandleForm"
data-request-update="#results">
Go
Run Code Online (Sandbox Code Playgroud)
并在我的组件插件文件中
// Fetches everything
public function onRun() {
$order = items::orderBy('id', 'asc');
$this->items = $order->get();
}
function onHandleForm()
{
// Fetch all of the items where category is 2 for test purposes
$order = items::orderBy('id', 'desc')->where('category','2');
$filter = $order->get();
$this->page['items'] = $filter; …Run Code Online (Sandbox Code Playgroud) 我有一个bash脚本创建tar.gz并加密然后发送到驱动器.但是之后我无法打开.tar.gz.这是我的过程......
加密的Bash脚本.
#!/bin/sh
# tar the automysqlbackup directory
tar -zcf "red-backup-$(date '+%Y-%m-%d').tar.gz" /var/lib/automysqlbackup/
# encrypt the tar
openssl aes-256-cbc -a -salt -in "red-backup-$(date '+%Y-%m-%d').tar.gz" -out "red-backup-$(date '+%Y-%m-%d').tar.gz.enc" -pass 'pass:MySecretPWD'
# remove the original tar
rm -rf "red-backup-$(date '+%Y-%m-%d').tar.gz"
# upload to google drive
gdrive upload --file "red-backup-$(date '+%Y-%m-%d').tar.gz.enc" -p "jofhriout849uioejfoiu09"
Run Code Online (Sandbox Code Playgroud)
然后我下载文件并使用
sudo openssl aes-256-cbc -e -in red-backup-2016-09-22.tar.gz.enc -out red-backup-2016-09-22.tar.gz
Run Code Online (Sandbox Code Playgroud)
然后我输入我的文件的密码两次,我现在得到一个名为的文件
red-backup-2016-09-22.tar.gz
Run Code Online (Sandbox Code Playgroud)
当我尝试
sudo tar -zxvf red-backup-2016-09-22.tar.gz
Run Code Online (Sandbox Code Playgroud)
得到
gzip: stdin: not in gzip format
tar: Child returned status 1
tar: Error …Run Code Online (Sandbox Code Playgroud) 我试图将查询结果传递给我在Express中的视图.查询是使用mongodb进行的,mongodb计算集体用户的总点数.
当我尝试将计数作为变量传递时,我得到了
ReferenceError: /Sites/test/views/dashboard.ejs:76
Run Code Online (Sandbox Code Playgroud)
在我的ejs视图中引用<%= totalpoints%>.下面是我在app.js中的代码
app.get('/dashboard', function(req, res) {
User.find({}, function(err, docs) {
console.log(docs);
});
User.find({
points: {
$exists: true
}
}, function(err, docs) {
var count = 0;
for (var i = 0; i < docs.length; i++) {
count += docs[i].points;
}
return count;
console.log('The total # of points is: ', count);
});
var totalpoints = count;
res.render('dashboard', {
title: 'Dashboard',
user: req.user,
totalpoints: totalpoints
});
});
Run Code Online (Sandbox Code Playgroud)
我有什么想法可以通过查询结果?
我正在使用带有nodejs的sendgrid api,并且出于某种原因,电子邮件正在发送但不添加新行.我已经习惯了,但是没有运气.知道什么是错的吗?
这是我正在使用的代码
var email = {
to: 'test@gmail.com',
from: 'hello@test.com',
subject: 'Membership',
text: 'Please view in html',
html: 'Hello there!,</br>\n\n' +
'Please click on the following link, or paste this into your browser to complete the process:\n\n' +
'Welcome and thanks for joining.\n\n' +
'</br>Your details we have are\n\n' +
'</br> Name: ' + user + '\n\n' + '</br> Telephone number: ' + number + '</br> email: ' + email + '</br>'
};
Run Code Online (Sandbox Code Playgroud) 我真的想让我的页脚响应不同的设备,所以我使用了cloudinary的发生器.这是HTML5
<picture>
<img
sizes="(max-width: 1920px) 100vw, 1920px"
srcset="
footer_rainbow_fjrr5j_c_scale,w_190.png 190w,
footer_rainbow_fjrr5j_c_scale,w_780.png 780w,
footer_rainbow_fjrr5j_c_scale,w_1190.png 1190w,
footer_rainbow_fjrr5j_c_scale,w_1920.png 1920w"
src="footer_rainbow_fjrr5j_c_scale,w_1920.png"
alt="">
</picture>
Run Code Online (Sandbox Code Playgroud)
但是根据caniuse.com,它不支持IE 10或11.
什么是最好的后备?到目前为止,我所能想到的是使用带有不同断点的css的媒体查询.有没有更好的办法?我也试过css封面,宽度; 100%并且包含,但两者都不是完美的.
我'url'在这段代码中引用这个错误.
未捕获的ReferenceError:未定义url.
尽管URL在ajax上方的变量中明确定义.我究竟做错了什么?
$.ajax({
url: url,
dataType: 'jsonp',
cache: true,
jsonpCallback: 'wCallback_1'
});
Run Code Online (Sandbox Code Playgroud)
这是完整的代码
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js"></script>
<script type="text/javascript" language="javascript">
$(function () {
// Specify the location code and units (f or c)
var location = 'SPXX0550';
var u = 'c';
// Run the query (pull data from rss feed)
var query = 'SELECT * FROM rss WHERE url="http://xml.weather.yahoo.com/forecastrss/' + location + '_' + u + '.xml"';
var cacheBuster = Math.floor((new Date().getTime()) / 1200 / 1000);
var url …Run Code Online (Sandbox Code Playgroud) 我有一个关联,输出键和值中的空格.我需要从第一个字母和最后一个字母中删除空格,并保留其间的空格.
我试过了
$stripResults = array_filter(array_map('trim', $results));
Run Code Online (Sandbox Code Playgroud)
这样可以完美地剥离值,但不是键.如何剥离密钥和值?
我试图在使用显示/隐藏的div上使用CSS动画toggle().
我添加ease-in-out了我的动画,但它只淡入,不会淡出.
这是我的css:
#form {
display: none;
animation: formFade 2s ease-in-out;
-moz-animation: formFade 2s ease-in-out; /* Firefox */
-webkit-animation: formFade 2s ease-in-out; /* Safari and Chrome */
-o-animation: formFade 2s ease-in-out; /* Opera */
}
@keyframes formFade {
from {
opacity:0;
}
to {
opacity:1;
}
}
@-moz-keyframes formFade { /* Firefox */
from {
opacity:0;
}
to {
opacity:1;
}
}
@-webkit-keyframes formFade { /* Safari and Chrome */
from {
opacity:0;
}
to { …Run Code Online (Sandbox Code Playgroud) 我有一个模型,其文件关系使用OctoberCMS的system_files.
public $attachOne = [
'return_file' => ['System\Models\File', 'public' => false, 'delete' => true]
];
Run Code Online (Sandbox Code Playgroud)
在fields.yaml我有表格
return_file:
label: Attach File
type: fileupload
mode: file
span: right
Run Code Online (Sandbox Code Playgroud)
现在,在我保存之前或之后,我想将图像从其目录移动到我的插件中的自定义目录.afterSave()似乎没有检索文件路径来移动它.
但是在system_files中我看到MySQL workbench实际上已经上传了它.
然而,当我在后端点击保存时,我得到"试图获得非物体的属性"
这是afterSave()函数中的内容.
public function afterSave()
{
$custom_path = plugins_path() . '/acme/request/uploads/';
$file = $this->return_file->getPath();
$move_file = $file->move($custom_path);
}
Run Code Online (Sandbox Code Playgroud)
甚至可以在后端上传并在保存之前/之后移动文件?
我试图使用waypoints.js在滚动以点击元素时使元素淡化.
我有
$(document).ready(function(){
$('.card').waypoint(function(down) {
console.log('hit element');
$(this).addClass('card-fadeIn');
}, { offset: '100%' });
});
Run Code Online (Sandbox Code Playgroud)
这样做会增加类'card-fadeIn',它是不透明度1和动画的简易性.
当我改为
$('.card').addClass('card-fadeIn');
Run Code Online (Sandbox Code Playgroud)
它工作正常,但为每个卡类添加了不透明度1并破坏了淡化效果.我试图使用$(this)而不是fadein,也不会在控制台中出错.有什么想法吗?
目前我的 WordPress 仪表板上有此通知。
我已在加载的配置文件中将 php 限制设置为 128m。然后我回显信息,它说 128m
我已将 wp-config.php 文件设置为包含
define( 'WP_MEMORY_LIMIT', '128M' );
Run Code Online (Sandbox Code Playgroud)
然后我使用以下命令重新启动了 apache 以确保进行更改。
sudo service apache2 restart
Run Code Online (Sandbox Code Playgroud)
然而,当我登录仪表板时,我仍然看到
Current memory limit: 40 MB | We recommend setting memory to at least 128MB
Run Code Online (Sandbox Code Playgroud)
我还检查了我的 .htaccess 文件(只有 mod_rewrite 设置),并且我仍然在仪表板中得到当前内存限制:40mb。
有什么想法吗?
我希望两个图像相互重叠,背面的动画图像和静态图像重叠.没有动画,它可以正常工作,红色与黑色图像重叠.
一旦我添加了css动画,它就会忽略z-index集,黑色与红色重叠.如何将红色图像置于正面?
我有一个使用CSS背景的工作解决方案,但我希望图像能够响应
这是一个小提琴
http://jsfiddle.net/52VtD/7992/
在这里
.rotate{
z-index: 1;
-webkit-animation:rotation 20s linear infinite;
-o-animation:rotation 20s infinite linear;
-moz-animation:rotation 20s infinite linear;
animation:rotation 20s infinite linear;overflow:visible;}
@keyframes rotation{0%{}100%{transform:rotate(-360deg);}}@-moz-keyframes rotation
{
0% {}
100% {transform: rotate(-360deg);}}
@-webkit-keyframes rotation
{
0% {}
100% {-webkit-transform: rotate(-360deg);}
}
@-o-keyframes rotation
{
0% {}
100% {-webkit-transform: rotate(-360deg);}
}
.static {
z-index:10;
margin-top: -232px;
}
Run Code Online (Sandbox Code Playgroud) 我收到一个日期,它使用 javascript 的 date() 函数来生成这样的时间戳。
1451351941210
Run Code Online (Sandbox Code Playgroud)
但是我的应用程序在 php 中,我想将该值转换为如下所示的 unix 时间戳
1451419198
Run Code Online (Sandbox Code Playgroud)
我试过除以 1000,但函数返回 18 年而不是 18 秒。
这是下面的代码
<?php
// Get javascript date() value
$date = 1451351941210;
// divide by 100 and round
$start_time = round($date/1000);
// run through function and echo
echo time_elapsed_string('@'. $start_time);
// Time function
function time_elapsed_string($datetime, $full = false) {
$now = new DateTime;
$ago = new DateTime($datetime);
$diff = $now->diff($ago);
$diff->w = floor($diff->d / 7);
$diff->d -= $diff->w * 7;
$string = array(
'y' …Run Code Online (Sandbox Code Playgroud)