小编Dha*_*iri的帖子

Typeahead Bloodhound POST请求

我似乎无法获得正确使用POST的远程查询.

var creditors = new Bloodhound({
    datumTokenizer: function (d) {
        return Bloodhound.tokenizers.whitespace(d.value)
    },
    queryTokenizer: Bloodhound.tokenizers.whitespace,
    remote: {
        url: "../getCreditors",
        replace: function(url, query) {
            return url + "#" + query;
        },
        ajax : {
            type: "POST",
            data: $.param({q: queryInput.val()})
        }
    }
});
Run Code Online (Sandbox Code Playgroud)

queryInput.val()只获取对象的当前值,而不是实例化bloodhound对象时的值.如何将查询字符串放入ajax数据选项中?

jquery typeahead typeahead.js twitter-typeahead

17
推荐指数
2
解决办法
2万
查看次数

Twitter的Typeahead - 调试渲染的HTML?

我在调试Twitter的Typeahead脚本时遇到问题.出于某种原因,以下标题显示正常...

header: '<h3 class="tt-title">Ads</h3>',
Run Code Online (Sandbox Code Playgroud)

但是,当我将div更换为div时,如下所示......

header: '<div class="tt-title">Ads</div>',
Run Code Online (Sandbox Code Playgroud)

我得到空白.我知道有些东西在渲染,但文字现在出现了.我觉得这是一个CSS问题,但我无法查看开发人员工具中下拉列表的呈现HTML.在我有机会在源中导航到下拉之前,下拉菜单会自动关闭.

任何人都知道如何阻止它一旦打开关闭?我正在使用Chrome的开发者工具.

css debugging developer-tools typeahead.js twitter-typeahead

12
推荐指数
2
解决办法
3439
查看次数

信用卡即将到期时发送条带通知

Stripe有没有办法在信用卡即将到期时自动向客户发送电子邮件?

stripe-payments stripe.net

11
推荐指数
2
解决办法
6640
查看次数

将自定义适配器与Ember CLI中的特定模型相关联

我们最近从Ember切换到Ember CLI,我无法找到将模型与自定义适配器关联的正确约定.

历史 我们为模型创建了一个适配器,这些模型将文件上传作为其创建路径的一部分,以便可以将表单数据和二进制数据推送到后端api [rails]中的一个端点.适配器使用FormData对象将文件添加到请求.我选择仅将此适配器用于包含文件的模型,并且非文件上载模型使用应用程序适配器.所以我希望ember应用程序支持多个适配器.

自定义适配器: 在adapters/file-upload.js中

import DS from 'ember-data';

var FileUploadAdapter = DS.ActiveModelAdapter.extend({
    ajaxOptions: function(url, type, hash) {
        var self = this;
        hash = hash || {};
        hash.url = url;
        hash.type = type;
        hash.dataType = 'json';
        hash.context = this;

        //add post data to formdata object
        if (hash.data && type != 'GET' && type !='DELETE') {
          hash.processData = false;
          hash.contentType = false;
          var fd = new FormData();
          var root = Object.keys(hash.data)[0];

          for (var i = 0; i < Object.keys(hash.data[root]).length; …
Run Code Online (Sandbox Code Playgroud)

ember.js ember-cli

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

Typeahead:未捕获错误缺少源

我每次尝试运行以下代码时都会在控制台中收到此错误

$('#autcomplete_search').typeahead({
  highlight: true
},
{
  name: 'apple_game',
  remote: "/search/autocomplete?keyword=make"
});
Run Code Online (Sandbox Code Playgroud)

typeahead bootstrap-typeahead

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

Twitter类型自动完成动态添加输入

我在我的网站上使用Twitter typeahead,它工作正常.但是当我尝试动态添加新输入时,它不起作用.可能是什么问题呢?

谢谢你的回复.

    var custom = new Bloodhound({
    datumTokenizer: function(d) { return d.tokens; },
    queryTokenizer: Bloodhound.tokenizers.whitespace,
    remote: 'http://'+window.location.hostname+'/invoice/loadItemOption?query=%QUERY'
    });

    custom.initialize();

    $('.typeahead_option_items').typeahead(null, {
          name: 'item_title[]',
          displayKey: 'invoice_item_option_title',
          source: custom.ttAdapter(),
          hint: (App.isRTL() ? false : true),
    }).on('typeahead:selected', function (obj, value) {
        console.log(value.invoice_item_option_title);
    });
Run Code Online (Sandbox Code Playgroud)

jquery typeahead.js twitter-typeahead

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

Ember-CLI:申请路线在哪里?

我正在尝试安装npm包rails-csrf.rails-csrf github站点上的说明说"将之前的模型添加到应用程序路由中,以便自动获取令牌".申请途径在哪里?

我认为它应该是app/routes/application.js但该文件不存在.不应该使用ember new命令默认创建吗?

ruby-on-rails ember.js ember-cli

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

如何在HTMLBars中编写助手?

在最新发布的EmberJS之后,v1.9.0我试图从Handlebars转移到HTMLbars.我发现非常具有挑战性的是缺乏文档.

我正在尝试实现非常简单的帮助器.

例如,拿这个把手帮手:

HTML

<div id="main"></div>

<script type="text/x-handlebars" data-template-name="index">
    {{logIt test}}
    <h1>{{test}}</h1>
</script>
Run Code Online (Sandbox Code Playgroud)

JS

App = Ember.Application.create({
    rootElement: '#main'
});

    App.IndexRoute = Ember.Route.extend({
        setupController: function(controller){
            controller.set('test', 'mytest');
        }
    });

    Ember.Handlebars.registerHelper("logIt", function(something) {
        console.log(something);
    });
Run Code Online (Sandbox Code Playgroud)

Js Fiddle:http://jsfiddle.net/sisir/p463q2L8/

如何将其转换为htmlbars?

javascript handlebars.js ember.js handlebarshelper htmlbars

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

ember-cli-live-reload Uncaught SyntaxError:意外的令牌<

其他人在浏览器控制台中收到此警告?页面首次加载时始终位于第一行.

Uncaught SyntaxError: Unexpected token <          ember-cli-live-reload.js:1 
Run Code Online (Sandbox Code Playgroud)

我的堆栈:

 DEBUG: -------------------------------
ember.js:3935 DEBUG: Ember                     : 1.9.1
ember.js:3935 DEBUG: Ember Data                : 1.0.0-beta.14.1
ember.js:3935 DEBUG: Handlebars                : 2.0.0
ember.js:3935 DEBUG: jQuery                    : 1.11.2
ember.js:3935 DEBUG: Ember Simple Auth         : 0.7.2
ember.js:3935 DEBUG: Ember Simple Auth Testing : 0.7.2
ember.js:3935 DEBUG: -------------------------------
Run Code Online (Sandbox Code Playgroud)

ember.js ember-cli

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

Git推送错误的heroku应用程序

我肯定这完全是基于我对git缺乏了解,问题是我不知道我不知道的是什么.

我有一个成功的应用程序部署到Heroku.它跟踪我的消防部门的工作订单.在我的正常工作流程中,我使用$ git push heroku masterapp目录来部署我的更改.我需要为另一个消防部门设置相同的应用程序.所以我想我会在我的本地机器上复制它,设置一个新的heroku应用程序,进行所需的更改,使新的副本特定于新的消防部门.我会运行git init等,然后将其推送到新的heroku应用程序.问题是,它推向旧的.我想这是因为我复制app目录时复制了所有的git设置.如何将其分开,以便它们像2个独特的应用程序一样?

是否有一些git的特征/区域我应该学习如何理解这里发生了什么?

git heroku

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

Stripe Payment网关我想以十进制格式使用金额

我正在我的网站上实现Stripe Payment gateway(php).我想以十进制形式发送订阅金额.例如,我想发送9.99,但它给我一个错误,它是一个无效的整数.为什么这不起作用?

stripe-payments

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

如何使用Ember CLI在Ember中进行依赖注入?

首先,我制作了一个没有Ember CLI的小型Ember应用程序.

我有这段代码.

window.MyApp = Ember.Application.create({
  ready: function() {
    this.register('session:current', MyApp.SessionController, { singleton: true });
    this.inject('controller', 'session', 'session:current');
  }
});
Run Code Online (Sandbox Code Playgroud)

这很有效.

然后我决定用Ember CLI从头开始重写所有内容.

我编辑了文件app/app.js并添加了ready钩子,就像我以前的版本一样.

var App = Ember.Application.extend({
  modulePrefix: config.modulePrefix,
  podModulePrefix: config.podModulePrefix,
  Resolver: Resolver,
  ready: function() {
    this.register('session:current', App.SessionController, { singleton: true });
    this.inject('controller', 'session', 'session:current');
  }
});
Run Code Online (Sandbox Code Playgroud)

这不起作用.

会话控制器确实存在.那是文件的内容app/controllers/session.js

export default Ember.Controller.extend({
  isLoggedIn: false,
});
Run Code Online (Sandbox Code Playgroud)

我得到的错误信息是

TypeError: Attempting to register an unknown factory: `session:current`
Run Code Online (Sandbox Code Playgroud)

它出现在浏览器中.

我用google搜索了这条消息,但我在Ember CLI中找不到依赖注入.

任何的想法?

ember.js ember-cli

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