小编Jef*_*ler的帖子

如何在Mithril JS中等待AJAX​​请求时显示微调器?

我在一个项目中使用Mithril JS而且我很难理解如何进入Ajax生命周期.就像我有一个Ajax请求需要一段时间,我想展示一个微调器.非常基本,但我似乎无法弄清楚这是怎么发生的.

我想为微调器使用相同的容器作为Ajax请求所寻找的内容.

这是我的设置:

var Thing = function (data) {
  var p = m.prop;
  this.title = p(data.title);
  this.timestamp = p(moment.unix(data.timestamp));
}

Thing.list = function(options) {
  m.request({method: "GET", url: "/things.json", type: Thing, background: true});
};

MyApp.components.thingsList = {
  controller: function ThingListController() {
    this.things = m.prop([]);
    Thing.list().then(this.things).then(m.redraw);
  },

  view: function thingListView(ctrl) {
    return m('div#thing-tab', [
      m('ul#things', [
        ctrl.things().map(thingView)
      ])
    ]);
  }
};

function thingView(thing) {
  ...some view stuff...
}
Run Code Online (Sandbox Code Playgroud)

我已经按照我想要的方式工作,但我无法弄清楚如何挂钩到ajax生命周期.同样,我只是想在请求开始时显示一个微调器,然后将其替换为ajax请求的结果.

非常感谢任何和所有的帮助!

谢谢,

javascript ajax mithril.js

11
推荐指数
1
解决办法
2229
查看次数

带子查询的MySQL更新

我有一个令人烦恼的问题,我正在尝试使用更新查询...以下语句应该将channels.media_view_count更新为子查询的结果(适用于所有通道).

UPDATE channels c
SET c.media_view_count = (
    SELECT SUM(t.view_count)
    FROM (
      SELECT DISTINCT m.viewkey, m.view_count
      FROM media m
      INNER JOIN participants p ON m.id = p.medium_id
      WHERE p.user_id = c.id AND m.is_viewable = 1
            AND (p.pending = 0)
      ) AS t
  );
Run Code Online (Sandbox Code Playgroud)

子查询独立工作(当指定c.id的实际id时,如47778或其他),但是当我执行此语句时,我得到:

ERROR 1054 (42S22): Unknown column 'c.id' in 'where clause'
Run Code Online (Sandbox Code Playgroud)

我以为我能够从子查询中访问channels表(别名为c)?我错过了什么或者我在这里完全错了吗?

任何和所有的帮助表示赞赏:)

谢谢,

  • 杰夫

mysql sql subquery

1
推荐指数
1
解决办法
6053
查看次数

在具有子域的单个Nginx上运行多个Rails应用程序

我试图弄清楚如何在子域下的服务器上运行第二个Rails应用程序。这是我的设置:

(App1)Primary Rails应用-> http://humani.se

(App2)Secondary Rails应用-> http://supportme.humani.se

域名是通过GoDaddy购买的,目前,我有一个指向http://humani.se:3000的子域(通过GoDaddy面板),您可以通过访问该URL来查看其作品。我知道,我知道-App1在生产中运行,而App2在开发中运行,不是很好的做法。我只是想看看我能否使其正常工作。

Nginx Conf:

# Primary Application Server
upstream humanise {
  # for UNIX domain socket setups:
  server unix:/home/jeff/srv/humani.se/tmp/sockets/unicorn.sock fail_timeout=0;
  # server localhost:8080;
}

server {
  server_name humani.se www.humani.se;

  # path for static files
  root /home/jeff/srv/humani.se/public;

  try_files $uri/index.html $uri.html $uri @humanise;

  location @humanise {
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header Host $http_host;
    proxy_redirect off;
    # proxy_pass http://unix:/home/jeff/srv/humani.se/tmp/sockets/unicorn.sock;
    proxy_pass http://humanise;
  }

  error_page 500 502 503 504 /500.html;
  client_max_body_size 4G;
  keepalive_timeout 10;
}

# Secondary Application …
Run Code Online (Sandbox Code Playgroud)

ruby subdomain ruby-on-rails nginx

1
推荐指数
1
解决办法
1229
查看次数

标签 统计

ajax ×1

javascript ×1

mithril.js ×1

mysql ×1

nginx ×1

ruby ×1

ruby-on-rails ×1

sql ×1

subdomain ×1

subquery ×1