小编Cra*_*den的帖子

在EmberJS 1.0.0-pre.4中检测路由转换

我试图检测何时发生路由转换.我已将此代码段放在最新版本的Ember(v1.0.0-pre.4)中,用于处理转换:

  didTransition: function(infos) {
    // Don't do any further action here if we redirected
    if (infos[infos.length-1].handler.transitioned) { return; }

    var appController = this.container.lookup('controller:application'),
        path = routePath(infos);

    set(appController, 'currentPath', path);
    this.notifyPropertyChange('url');

    if (get(this, 'namespace').LOG_TRANSITIONS) {
      Ember.Logger.log("Transitioned into '" + path + "'");
    }
  },
Run Code Online (Sandbox Code Playgroud)

我将我的Ember应用程序设置为window.App = Ember.Application.create().

我注意到它调用了this.notifyPropertyChange('url');,但我试图将一个观察者附加到我的应用程序,App.Router或者App.Router.router我得到一个错误,因为它没有实现Ember.Observable.

如何更改路径路径而不为每条路线创建特殊的Ember.Route?

ember.js ember-router

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

Javascript:Eventhandler无法运行,可以在JSFiddle中运行

所以这是我发布的另一个问题的答案,我认为这是正确的解决方案.然而,虽然它在jsfiddle中运行得非常好,但它在该环境之外并不起作用.我尝试了多种组合,但我无法正常工作.

我已经尝试onLoad了在主体中,Window.onload在标题环绕函数并在所有元素加载后在页面底部单独调用它.什么都行不通.

我总是遇到这个问题:

未捕获的TypeError:无法调用null的方法'addEventListener'

这是令人沮丧的,因为我看到的所有其他解决此错误的解决方案都围绕着确保您确实拥有处理程序在HTML中触发的指定ID.我做的.

我知道在这里发帖子可能有点过头了但是我把头发拉了出来.

这是JSfiddle:http://jsfiddle.net/fFW5r/1/

这是我用来测试概念的模型页面(它永远不会起作用):

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>

<script type="text/javascript"> 
    var link_container = document.getElementById('links');
    function myFunction(){ link_container.addEventListener('click', function(e){ 
        if(e.target.nodeName === "A"){
            var href = e.target.getAttribute('href'),
                selfhost = window.location.hostname;
            if(href.indexOf(selfhost) !== -1){
                alert('Inbound link clicked');
            } else {
                alert('Outbound link clicked');
            }
        }
    }, false); 
    }
</script>
</head>

<body onload="myFunction()">

<div id="links">
    <a href="http://fiddle.jshell.net/#foo">Inbound Link</a>
    <a …
Run Code Online (Sandbox Code Playgroud)

javascript event-handling jsfiddle

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

整数幂c

我一直在研究一些基本的编码,我正在努力找出正确的扫描方式,第一个是我的x变量,第二个是x被提升到的n.我尝试5 ^ 5并使用我当前的代码获得-287648.

#include <stdio.h>
#include <math.h>

void x_to_the_n (void)
{
    int x=0;
    int n =0;
    long int y;
    printf("Enter a integer for X and N\n");
    scanf("%i\n%i\n",&x,&n);
        y=pow(x,y);
        printf("%i \n",y);
}

int main(void)
{
    x_to_the_n ();
    return 0;
}   
Run Code Online (Sandbox Code Playgroud)

c integer

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

django - 模板中的列表列表

我正在尝试呈现用 .zip 压缩的列表列表zip()

list_of_list = zip(location,rating,images)
Run Code Online (Sandbox Code Playgroud)

我想将其渲染list_of_list到模板并只想显示每个位置的第一张图像。

我的位置和图像模型是这些:

class Location(models.Model):
  locationname = models.CharField

class Image(models.Model):
  of_location = ForeignKey(Location,related_name="locs_image")
  img = models.ImageField(upload_to=".",default='')
Run Code Online (Sandbox Code Playgroud)

这是压缩列表。如何仅访问模板中每个位置的第一张图像?

在此处输入图片说明

python django django-templates

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

Ember Router 转换为带参数的嵌套路由

App.Router.map(function() {
    this.resource('documents', { path: '/documents' }, function() {
        this.route('edit', { path: ':document_id/edit' });
    });
    this.resource('documentsFiltered', { path: '/documents/:type_id' }, function() {
        this.route('edit', { path: ':document_id/edit' });
        this.route('new');
    });
});
Run Code Online (Sandbox Code Playgroud)

这个控制器带有一个子视图事件,基本上转换为过滤后的文档

App.DocumentsController = Ember.ArrayController.extend({
    subview: function(context) {
    Ember.run.next(this, function() {
        //window.location.hash = '#/documents/'+context.id;
        return this.transitionTo('documentsFiltered', context);
    });
},
});
Run Code Online (Sandbox Code Playgroud)

我的问题是,当页面哈希值更改时,此代码可以正常工作。

但是当我运行上面的代码而不使用 location.hash 位并且使用 Ember 本机时,transitionTo我得到了一个神秘的信息

未捕获的类型错误:对象 [object Object] 没有方法“切片”

有什么线索吗?

谢谢

更新:

App.DocumentsFilteredRoute = Ember.Route.extend({
model: function(params) {
    return App.Document.find({type_id: params.type_id});
},
});

{{#collection contentBinding="documents" tagName="ul" class="content-nav"}}
<li …
Run Code Online (Sandbox Code Playgroud)

ember.js ember-data

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

ios应用程序崩溃没有错误(即使通过按钮点击调用空操作)

我发现了类似的问题,但没有一个解决了我的问题.

有一些viewcontrollers和工作应用程序.

我向其中一个viewcontrollers添加了一个按钮,并绑定了一个"sampleclick"动作.此操作中没有任何内容(没有代码,没有行,只是一个空方法),应用程序与以下块崩溃:

所有输出日志:

(lldb)
Run Code Online (Sandbox Code Playgroud)

和堆栈:

libobjc.A.dylib`objc_msgSend:
0x10ed08c:  movl   8(%esp), %ecx
0x10ed090:  movl   4(%esp), %eax
0x10ed094:  testl  %eax, %eax
0x10ed096:  je     0x10ed0e8                 ; objc_msgSend + 92
0x10ed098:  movl   (%eax), %edx
0x10ed09a:  pushl  %edi
0x10ed09b:  movl   8(%edx), %edi
0x10ed09e:  pushl  %esi
***0x10ed09f:  movl   (%edi), %esi   >>> crashes here with :Thread1:EXC_BAD_ACCESS*** (code=1,address: .....)
0x10ed0a1:  movl   %ecx, %edx
0x10ed0a3:  shrl   $2, %edx
0x10ed0a6:  andl   %esi, %edx
0x10ed0a8:  movl   8(%edi,%edx,4), %eax
0x10ed0ac:  testl  %eax, %eax
0x10ed0ae:  je     0x10ed0b9                 ; objc_msgSend + 45
0x10ed0b0:  cmpl …
Run Code Online (Sandbox Code Playgroud)

crash error-handling ios

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

将我的共享库链接到另一个库(CMAKE)

我目前正在尝试将我编写的CXX库链接到VTK,一个CMake制作的库 - 最终创建一个具有我的代码功能的共享库,并可以解析VTK中的符号.我需要共享最终结果,因为我需要在运行时用Java调用库.

linker cmake shared-libraries

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

PHP打印代码(打印成纸)

是否有PHP函数从网页(浏览器内)打印东西?

我在谷歌搜索但结果是print()功能.或者您可以分享的任何想法或任何网络编程语言.我需要一个代码来打印我的数据库中的主题列表.对不起这个愚蠢的问题.我不知道这是否可能.

php

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

用于删除Ghost换行符的VIM脚本

有没有办法使用Vim脚本或搜索/替换来删除鬼换行?我遇到过这样的情况,当我必须编辑文件时,其他使用蹩脚软件的开发人员已经在附图中留下了双重换行符.

我很想在Vim找到一种方法来删除所有那些愚蠢的双间距垃圾,所以它实际上看起来应该如此.

在此输入图像描述

linux vim

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

媒体行中的媒体格式(有效载荷类型编号)与rtpmap不同

在测试SIP视频通话时,我在提供的媒体的答案中得到了以下媒体专线信息。这是有效的媒体行吗?媒体格式编号与rtpmap编号不同:

m=video 49218 RTP/AVP 109
b=TIAS:322000
a=rtpmap:96 H264/90000
a=fmtp:96 profile-level-id=42801f; max-mbps=216000; max-fs=3600; sar=13
a=sendonly
Run Code Online (Sandbox Code Playgroud)

sip sdp

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

为什么我看到"加载路线时出错"与ember?

ember rc1,ember-data rev 12.所有其他路由正确加载,不确定为什么我看到这个错误.当我尝试访问show route即/ files/groups/5时会发生这种情况.索引路线呈现良好.

我已经粘贴了下面的堆栈跟踪,但它的信息量不大.我在这里做什么基本上是错的?

我的路线/控制器设置如下:

this.resource('files', { path : '/files' }, function() {      
  this.resource('groups', { path : '/groups' }, function() {      
    this.route('show', { path : '/:asset_link_group_id' });      
  });
});

AssetLinksApp.GroupsShowController = Ember.ArrayController.extend({
  content : Ember.A(),
  assetLinkGroup : null
});

AssetLinksApp.GroupsShowRoute = AssetLinksApp.AuthRequiredRoute.extend({
  setupController : function(controller,model) {    
  controller.set('content',model.get('asset_links'));
  controller.set('assetLinkGroup',model);
  },
  model : function(params) {    
    return AssetLinksApp.AssetLinkGroup.find(params.asset_link_group_id);
  }
});
Run Code Online (Sandbox Code Playgroud)

堆栈跟踪:

加载路由时出错:TypeError {} exchange_vendor.js:12078

(匿名函数)exchange_vendor.js:12078 Ember.Router.reopenClass.defaultFailureHandler.setup exchange_vendor.js:35011 failure exchange_vendor.js:34448 objects.concat.context exchange_vendor.js:34497 invokeCallback exchange_vendor.js:17846 Promise.then exchange_vendor. js:17893 EventTarget.trigger exchange_vendor.js:17822 results exchange_vendor.js:17924 …

ember.js ember-data

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

如何在远程服务器上的PHP5上安装cURL

我试图通过我的Mac在远程服务器上安装cURL,但由于某种原因我无法这样做.

以下是我遵循的步骤: -

  1. ssh'ed远程服务器
  2. wget http://curl.haxx.se/download/curl-7.14.0.tar.gz
  3. zcat curl-7.14.0.tar.gz | tar xvf -
  4. cd curl-7.14.0 /
  5. make(给了我错误: - (如下))

    ./configure
    checking whether to enable maintainer-specific portions of Makefiles... no
    checking for sed... /usr/bin/sed
    checking for ar... ar
    checking for a BSD-compatible install... /usr/bin/install -c
    checking whether build environment is sane... yes
    checking for gawk... gawk
    checking whether make sets $(MAKE)... yes
    checking curl version... 7.14.0
    checking build system type... x86_64-unknown-linux-gnu
    checking host system type... x86_64-unknown-linux-gnu
    checking for style of include used …
    Run Code Online (Sandbox Code Playgroud)

php curl

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