我正在使用Moment.js创建一个资源日历,我需要一周的日期数组.我当前函数的控制台日志打印出来,但是每个日期推入的数组都是错误的.
var startOfWeek = moment().startOf('week');
var endOfWeek = moment().endOf('week');
var days = [];
var day = startOfWeek;
do {
console.log(day._d);
days.push(day._d);
day = day.add(1, 'd');
}
while (day <= endOfWeek);
console.log(days);
Run Code Online (Sandbox Code Playgroud)
返回:
Sun Jan 18 2015 00:00:00 GMT-0500 (EST) schedule.js?320233fd69f9859ccb55248b608e15891032b17d:31
Mon Jan 19 2015 00:00:00 GMT-0500 (EST) schedule.js?320233fd69f9859ccb55248b608e15891032b17d:31
Tue Jan 20 2015 00:00:00 GMT-0500 (EST) schedule.js?320233fd69f9859ccb55248b608e15891032b17d:31
Wed Jan 21 2015 00:00:00 GMT-0500 (EST) schedule.js?320233fd69f9859ccb55248b608e15891032b17d:31
Thu Jan 22 2015 00:00:00 GMT-0500 (EST) schedule.js?320233fd69f9859ccb55248b608e15891032b17d:31
Fri Jan 23 2015 00:00:00 GMT-0500 (EST) schedule.js?320233fd69f9859ccb55248b608e15891032b17d:31 …Run Code Online (Sandbox Code Playgroud) 我正在尝试在创建用户的个人资料时添加accountActive和accountExpirationDate.根据我读过的所有内容,我应该使用Accounts.onCreateUser,如下所示:
// Add accountActive and accountExpirationDate
Accounts.onCreateUser(function(options, user) {
if (options.profile) {
user.profile = options.profile;
user.profile.accountActive = false;
user.profile.accountExpirationDate = null;
}
return user;
});
Run Code Online (Sandbox Code Playgroud)
这两个字段没有添加,我在Console中收到此错误.
Uncaught TypeError: Object #<Object> has no method 'onCreateUser'
Run Code Online (Sandbox Code Playgroud)
我究竟做错了什么?
我正试图在分类列表中找到用户的杂货.关联是Category hasMany Item hasMany User through Grocery.我正在使用可包含行为,并没有过滤掉所有其他Grocery.它基本上返回每个项目.
我的控制器功能:
function showlist() {
$categories = $this->Category->find('all', array(
'contain' => array(
'Item' => array(
'Grocery' => array(
'conditions' => array(
'Grocery.user_id =' => $this->Auth->user('id')
)
)
)
)
));
Run Code Online (Sandbox Code Playgroud)
返回的数组:
Array
(
[0] => Array
(
[Category] => Array
(
[id] => 10
[parent_id] =>
[name] => Dairy
[lft] => 1
[rght] => 6
)
[Item] => Array
(
)
)
[1] => Array
(
[Category] => Array
(
[id] => 11
[parent_id] …Run Code Online (Sandbox Code Playgroud) 我无法使用新的Auth组件测试用户是否处于活动状态.我有3个状态,用户可以进入:0未激活(默认),1激活,2激活.我正在尝试在登录功能中实现这一点,所以我可以返回他们是否已经注册或被禁止.
登录:
public function login() {
if ($this->request->is('post')) {
if($this->Auth->login()) {
$results = $this->User->find('all', array(
'conditions' => array('User.email' => $this->Auth->user('email')),
'fields' => array('User.is_active')
));
if ($results['User']['is_active'] == 0) {
// User has not confirmed account
$this->Session->setFlash('Your account has not been activated. Please check your email.');
$this->Auth->logout();
$this->redirect(array('action'=>'login'));
}
// not working atm
else if ($results['User']['is_active'] == 2) {
// User has been deactivated
$this->Session->setFlash('Your account has been deactivated. Contact site admin if you believe this is in error.');
$this->Auth->logout(); …Run Code Online (Sandbox Code Playgroud) 我在我的流星应用程序的首页上添加了一个表单,其中包含一封电子邮件和用户名.它会发送一个注册电子邮件,其中包含一个用于创建密码的链接.创建帐户时需要添加许多后台配置文件设置,并且它可以通过{{loginButtons}}帐户创建来运行.出于某种原因,从createUser调用onCreateUser时不起作用.我哪里出错了?提前致谢.
报名表:
<form role="form" class="form-horiztonal" id="signup">
<div class="form-group">
<label for="name" class="col-sm-3 control-label">Name</label>
<div class="col-sm-9">
<input name="name" id="name" class="form-control" type="text" placeholder="Name"/>
</div>
</div>
<div class="form-group">
<label for="email" class="col-sm-3 control-label">Email</label>
<div class="col-sm-9">
<input name="email" class="form-control" type="email" placeholder="example@gmail.com"/>
</div>
</div>
<div class="form-group">
<div class="col-sm-9 col-sm-offset-3">
<input type="submit" value="Get Started!" class="btn btn-success"/>
</div>
</div>
</form>
Run Code Online (Sandbox Code Playgroud)
页面事件:
Template.landing.events({
'submit form#signup' : function(e) {
e.preventDefault();
var user = {
name: $(e.target).find('[name=name]').val(),
email: $(e.target).find('[name=email]').val()
}
Meteor.call('signup', user, function(error, id) {
if (error) {
// display …Run Code Online (Sandbox Code Playgroud) 我想根据按下哪个按钮更改Nivo Slider的过渡效果.有关如何实现这一目标的任何想法?
更新 为了澄清,我的意思是下一个或上一个按钮,而不是键盘上的按钮.我正在寻找的是如果一个人按下下一个按钮,则调用slideToRight过渡效果.如果某人按下前一个按钮,则会调用slideToLeft过渡效果.如果有人按下特定的幻灯片,如果它滑动正确的方向,那么锦上添花就会结束.我喜欢Nivo Slider,但我觉得这些应该是默认的可选动作.
cakephp ×2
meteor ×2
account ×1
arrays ×1
cakephp-2.0 ×1
carousel ×1
containable ×1
javascript ×1
jquery ×1
momentjs ×1
nivo-slider ×1