小编Gaz*_*Gaz的帖子

调试消息"资源解释为其他但使用MIME类型application/javascript传输"

好的,我理解这些消息意味着什么,但我真的不确定是什么导致了它.顺便说一下,我在Mac OS X上使用Safari和Web Inspector.

我的文档头中有以下内容:

<script src="http://local.url/a/js/jquery.js" type="text/javascript"></script>
<script src="http://local.url/a/js/jquery.inplace.js" type="text/javascript"></script>
Run Code Online (Sandbox Code Playgroud)

jquery.js处理正常,但另一个文件导致警告.似乎这个文件中的javascript永远不会被执行.

该文件正在通过mod_deflate,因此它是gzip编码,但另一个文件也是如此.

有没有人知道是什么导致了这个问题,或者如何解决它?

干嘛,加兹.

javascript apache safari mime-types

64
推荐指数
5
解决办法
10万
查看次数

NPM没有创建.bin目录

我在Mac OS X 10.9.2上使用npm v1.4.4node v0.10.25.

我最近升级了node和npm,现在npm install不再在node_modules中创建.bin目录了.

我删除了node_modules,npm install再次尝试,但从未创建目录和二进制文件.

有没有人知道为什么会这样?

这是我的package.json:

{
  "name": "redacted",
  "author": {},
  "description": "redacted",
  "dependencies": {
  },
  "devDependencies": {
    "karma": "*",
    "karma-coverage": "0.1.2",
    "karma-junit-reporter": "*",
    "karma-coffee-preprocessor": "~0.1",
    "grunt": "^0.4.2",
    "grunt-contrib-requirejs": "^0.4.3",
    "grunt-contrib-concat": "^0.3.0",
    "grunt-contrib-sass": "^0.7.2",
    "grunt-contrib-htmlmin": "^0.2.0",
    "grunt-contrib-cssmin": "^0.7.0",
    "grunt-contrib-coffee": "^0.10.1",
    "grunt-contrib-uglify": "^0.3.3",
    "grunt-contrib-jst": "^0.5.1",
    "grunt-contrib-qunit": "^0.4.0",
    "grunt-contrib-jshint": "^0.8.0",
    "grunt-contrib-watch": "^0.5.3",
    "grunt-contrib-jasmine": "^0.6.1",
    "grunt-contrib-compress": "^0.6.1",
    "grunt-contrib-handlebars": "^0.6.1",
    "grunt-contrib-less": "^0.9.0",
    "grunt-contrib": "^0.9.0"
  }
}
Run Code Online (Sandbox Code Playgroud)

macos node.js npm

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

从jQuery回调引用CoffeeScript中的父类

我是CoffeScript的新手,我想知道是否有一种方法可以在不引用全局变量应用程序的情况下编写以下代码:

class App 

    constructor: ->
        @ui = ui.init()
        $('#content-holder a[rel!=dialog]').live 'click', ->
            link = $(@).attr 'href'
            app.loadUrl link
            return false

    loadUrl: (href) ->
        # ...

app = new App()
Run Code Online (Sandbox Code Playgroud)

使用胖箭头不起作用,因为我失去了对jQuery对象的引用,即

class App   
    constructor: ->
        @ui = ui.init()
        $('#content-holder a[rel!=dialog]').live 'click', =>
            # @ now references App
            link = $(@).attr 'href'
            this.loadUrl link
            return false

    loadUrl: (href) ->
        # ...
Run Code Online (Sandbox Code Playgroud)

第一段代码可以工作,但如果可能的话我想摆脱全局变量:-)

干杯,加兹.

javascript coffeescript

7
推荐指数
2
解决办法
3640
查看次数

调用 becomeFirstResponder 后,iOS UISearchBar 延迟显示键盘 - iOS7

我有一个 UISearchBar,它是一个 IBOutlet。点击搜索栏或调用[searchBar becomeFirstResponder]viewDidAppear 会导致 UI 在键盘出现之前锁定几秒钟的延迟。

我在 Instruments 中看过这个,当调用 becomeFirstResponder 时,CPU 使用率会出现峰值,但我不确定如何将其缩小到峰值中的一个方法/一组方法。

视图控制器没有做任何阻塞的事情,并且主线程上没有其他任何东西在运行(据我所知)。这只会在第一次调用 becomeFirstResponder 或点击搜索栏后发生。一旦键盘被关闭,它就不会再次发生。

任何帮助将不胜感激,因为我看不出真正有什么问题。

这一切都在 iOS7、iPhone 和 iPad 上运行。

objective-c uisearchbar ios ios7

5
推荐指数
0
解决办法
601
查看次数

PHP递归搜索和替换数组元素

我想以递归方式搜索和替换数组中的元素.

该数组是基于树的所以看起来像

Object
   Children
      Object type A
      Object type B
Object
   Children
      Object type A
Object
Run Code Online (Sandbox Code Playgroud)

等等

我希望能够用其他项替换某些项,所以例如,我想用类型B的数组替换类型A的数组(在任何深度级别)中的所有条目.但是这里是catch:新替换的对象也可能具有需要替换的A类子代.

到目前为止我已经有了

    foreach($nodes as &$node) {
        // Replace node?
        if($node['type'] == 'RefObject') {
            $n = $this->site->get_node_where('id', $node['node_ref']);
            // Replace node
            $node = $this->site->get_node_where('object_id', $n['object_id']);
            // Get children
            $node['children'] = $this->site->get_descendants($node['lft'], $node['rgt']);
        }
    }
    return $nodes;
Run Code Online (Sandbox Code Playgroud)

这将取代第一级RefObject,但不会搜索随后添加的子级.

我一直用这个砸我的头撞墙几个小时.请帮忙!

干杯,加兹.

php arrays recursion

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

Android:无法从View转换为MapView

我正在尝试运行Android MapView示例,并且在Eclipse中遇到了"无法从View转换为MapView"错误.

我的布局如下

<?xml version="1.0" encoding="utf-8"?>

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/mainlayout"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >

<com.google.android.maps.MapView
    android:id="@+id/mapview"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:clickable="true"
    android:apiKey="0jwi0saLYCPGfO-t7glg5bQoBz7jVKWCcgyQWQA"
 />

<LinearLayout
    android:id="@+id/zoomview"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignBottom="@id/mapview"
    android:layout_centerHorizontal="true"
/>

</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)

和活动代码是

package org.gaz.mapapp;

import android.os.Bundle;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.ZoomControls;

import com.google.android.maps.*;

public class MapView extends MapActivity {

LinearLayout linearLayout;
MapView mapView;
ZoomControls mZoom;

public void onCreate(Bundle savedInstance) {
    linearLayout = (LinearLayout) findViewById(R.id.mainlayout);
    mapView = (MapView) findViewById(R.id.mapview);
    mZoom = (ZoomControls) mapView.getZoomControls();       
}

@Override
protected boolean isRouteDisplayed() {
    // TODO Auto-generated method …
Run Code Online (Sandbox Code Playgroud)

android casting android-mapview

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