小编Pao*_*fan的帖子

Backbone.js - 在视图中过滤和显示集合数据的正确方法

我在开始时加载了大量任务.
我想根据所选列表/收件箱显示它们,这样每个列表都不会有额外的加载.

window.Task = Backbone.Model.extend({});

window.TasksCollection = Backbone.Collection.extend({
    model: Task,
    url: '/api/tasks',
    inbox: function() {
        return this.filter(function(task) {
            return task.get('list') == null;
        });
    },
    list: function(id) {
        return this.filter(function(task) {
            return task.get('list') == id;
        });
    }
});

window.tasks = new TasksCollection;

window.TaskView = Backbone.View.extend({
    tagName: 'li',
    template: _.template($('#item-template').html()),
    initialize: function() {
        _.bindAll(this, 'render', 'close');
        this.model.bind('change', this.render);
        this.model.view = this;
    },
    render: function() {
        $(this.el).html(this.template(this.model.toJSON()));
        this.setContent();
        return this;
    },
});

window.TasksView = Backbone.View.extend({
    el: '#todo-list',
    collection: tasks,
    initialize: function() {
        _.bindAll(this, …
Run Code Online (Sandbox Code Playgroud)

backbone.js

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

如何确定VBA中使用的最后一行,包括中间的空格

如何确定Excel工作表中的最后一行,包括中间的一些空行?

有了这个功能:

Function ultimaFilaBlanco(col As String) As Long        
        Dim lastRow As Long
        With ActiveSheet
            lastRow = ActiveSheet.Cells(ActiveSheet.Rows.Count, col).End(xlUp).row
        End With            
        ultimaFilaBlanco = lastRow          
End Function
Run Code Online (Sandbox Code Playgroud)

这个数据:

Row 1 : Value
Row 2 : Value
Row 3 : Value
Row 4 : Value
Row 5 : Value
Row 6 : White
Row 7 : Value
Row 8 : Value
Row 9 : Value
Row 10  : White
Row 11  : White
Row 12  : White
Row 13  : Value
Row 14 …
Run Code Online (Sandbox Code Playgroud)

excel vba

34
推荐指数
4
解决办法
21万
查看次数

如何在Raphael.js/IE中使模式"固定"?

我正在创建一个小工具来说明偏光镜片的好处.基本上,用户将镜头(Raphael.js路径)拖过一个令人眼花缭乱的场景(容器DIV的CSS背景)并"透视"镜头.这是js代码:

var rsr = Raphael("playmask", 720,540);
// Lens path
var path_f = rsr.path("M0,73.293c0.024-39.605,17.289-53.697,35.302-61.34C53.315,4.312,99.052-0.012,119.011,0 c38.56,0.021,43.239,11.164,43.229,29.9c-0.002,3.45-0.76,28.632-16.349,58.949c-10.332,20.092-28.434,60.424-76.452,60.396 C29.821,149.223-0.022,112.898,0,73.293 M200.594,29.922c0.011-18.734,4.699-29.871,43.262-29.851 c19.96,0.013,65.691,4.39,83.695,12.052c18.005,7.662,35.254,21.772,35.231,61.379c-0.023,39.606-29.909,75.896-69.526,75.872 c-48.02-0.027-66.076-40.377-76.384-60.484C201.32,58.557,200.594,33.373,200.594,29.922");

path_f.attr({"stroke-width":2, fill:'url(img/polarized.jpg)'} );

var move = function(dx,dy){
    this.translate( dx-this.ox, dy-this.oy );
    this.ox = dx;
    this.oy = dy;
},
start = function(){
    this.ox = 0;
    this.oy = 0;
},
end = function(){   
};

path_f.drag(move,start,end);
Run Code Online (Sandbox Code Playgroud)

#playmaskdiv有这个CSS(只是"非偏振"背景图像和尺寸):

#playmask{
    height:540px;
    width:720px;
    background: url(img/unpolarized.jpg);
}
Run Code Online (Sandbox Code Playgroud)

我坚持的是:

  • Chrome/Firefox一如既往地发挥出色:镜头形状显示出来,填充图像看起来"固定",同时拖动镜头(见第一张照片);
  • IE版本7,8,9可以工作,但是(惊喜!)它们的行为方式不同:填充图像"胶合"到镜头形状(参见第二张附图).

我在这里要问的是:我能否以相似的方式使IE9/8/7表现出来,即在拖动镜头时保持填充图像的固定?如果是这样,怎么样?

Firefox截图: Firefox 11.0中的行为

IE9截图: IE9中的行为

编辑 使用Modernizr检测浏览器功能,我注意到这种奇怪的行为似乎与IE 的"无笑"功能有关. 我发现IE9的一个奇怪的行为......背景不"粘",但如果我拖动面具,选择一些文字并按下鼠标右键,它会将"偏振"背景刷新到正确的位置!

编辑2(2012年5月21日)还没有解决方案:(但更确切地说,它与"无笑"功能无关 ;并且,重现IE9上的错误的正确方法是拖动玻璃周围,在页面的其余部分选择一些文字,然后滚动弹出的加速器图标(蓝色的箭头中有一个箭头).眼镜bg在正确的位置神奇地"刷新". …

javascript svg fill raphael drag

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

Gradle:错误:包含名称为"com.google.android.gms"的多个库

这个错误信息是什么意思?我的项目中没有重复的包

错误:任务':SimpleReader:processDebugResources'的执行失败.
错误:包含名称为"com.google.android.gms"的多个库
您可以使用android.enforceUniquePackageName = false临时禁用此错误但是,这是临时的,将在1.0中强制执行

build.gradle看起来像这样:

buildscript {

    repositories {
        maven { url 'http://repo1.maven.org/maven2' }
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:0.9.1'
    }
}
apply plugin: 'android'
android {
    buildToolsVersion '19.0.3'
    defaultConfig {
        minSdkVersion 14
        targetSdkVersion 17

    }
    compileSdkVersion 17
    packagingOptions {
        exclude 'META-INF/DEPENDENCIES'
        exclude 'META-INF/NOTICE'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/NOTICE.txt'
    }
    buildTypes {
    }
}
dependencies {
    compile 'com.android.support:support-v4:19.0.1'
    compile 'com.google.android.gms:play-services:4.2.42'
    compile files('libs/gson-2.2.4.jar')
    compile files('libs/httpmime-4.1.jar')
    compile files('libs/httpclient-4.1.1.jar')
    compile files('libs/jsoup-1.7.3.jar')
    compile project(':libraries:actionbarsherlock')
    compile project(':libraries:sherlocknavigationdrawer')
    compile project(':libraries:googleplayservices')
    compile …
Run Code Online (Sandbox Code Playgroud)

android gradle build.gradle android-gradle-plugin

33
推荐指数
3
解决办法
5万
查看次数

在Laravel中,'格式错误的UTF-8字符,可能是错误编码的'

我正在使用Laravel(一个PHP框架)为移动设备编写服务并以JSON格式返回数据.在数据结果中有一些字段编码UTF-8.

以下声明

return JsonResponse::create($data); 
Run Code Online (Sandbox Code Playgroud)

返回以下错误

InvalidArgumentException
HELP
Malformed UTF-8 characters, possibly incorrectly encoded

Open: /var/www/html/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/JsonResponse.php
        } catch (\Exception $exception) {
            restore_error_handler();

            throw $exception;
        }

        if (JSON_ERROR_NONE !== json_last_error()) {
            throw new \InvalidArgumentException($this->transformJsonError());
        }
Run Code Online (Sandbox Code Playgroud)

我改变了:

return JsonResponse::create($data);
Run Code Online (Sandbox Code Playgroud)

return JsonResponse::create($data, 200, array('Content-Type'=>'application/json; charset=utf-8' ));
Run Code Online (Sandbox Code Playgroud)

但它仍然无法正常工作.

我该如何解决?

php json utf-8 laravel-4

33
推荐指数
5
解决办法
9万
查看次数

'beforeunload'Chrome Issue

我有这段简单的代码 -

$(window).bind('beforeunload', function(){
    alert("Good Bye")
});
Run Code Online (Sandbox Code Playgroud)

适用于Firefox,IE8但不适用于Chrome.这是一个已知问题还是有其他替代方案?

实际上我想要做的是在用户试图关闭浏览器时记录细节.

function LogTime()
{
    jQuery.ajax({
      type: "POST",
      url: "log.php",
      data: "",
      cache: false,
      success: function(response)
      {
      }
    );
}

$(window).bind('beforeunload', function(){
    LogTime();
});
Run Code Online (Sandbox Code Playgroud)

这适用于Firefox,但不适用于Chrome

javascript jquery google-chrome

16
推荐指数
4
解决办法
3万
查看次数

Angular 6不会将X-XSRF-TOKEN标头添加到http请求

我已经阅读关于SO 的文档和所有相关问题,但是Angular的XSRF机制仍然不适合我:我绝不能自动附加X-XSRF-TOKEN标头发出POST请求.

我有一个带登录表单的Angular 6应用程序.

它是Symfony(PHP 7.1)网站的一部分,Angular应用程序页面,当从Symfony提供时,发送正确的Cookie(XSRF-TOKEN):

在此输入图像描述

我的app.module.ts包含正确的模块:

// other imports...
import {HttpClientModule, HttpClientXsrfModule} from "@angular/common/http";

// ...
@NgModule({
  declarations: [
    // ...
  ],
  imports: [
    NgbModule.forRoot(),
    BrowserModule,
    // ...
    HttpClientModule,
    HttpClientXsrfModule.withOptions({
      cookieName: 'XSRF-TOKEN',
      headerName: 'X-CSRF-TOKEN'
    }),
    // other imports
  ],
  providers: [],
  entryComponents: [WarningDialog],
  bootstrap: [AppComponent]
})
export class AppModule {
}
Run Code Online (Sandbox Code Playgroud)

然后,在Service的方法中,我正在进行以下http请求(this.http是一个实例HttpClient):

this.http
    .post<any>('api/login', {'_username': username, '_pass': password})
    .subscribe(/* handler here */);
Run Code Online (Sandbox Code Playgroud)

post请求永远不会发送X-XSRF-TOKEN标头.为什么?

csrf typescript x-xsrf-token angular angular6

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

尝试使用chr(128)获取欧元符号

我期待这段代码:

define('EURO_SIMBOLO', chr(128));
$euro = EURO_SIMBOLO;
var_dump($euro);
Run Code Online (Sandbox Code Playgroud)

显示符号,但它没有.为什么会这样?

php chr euro

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

Symfony 2 FOS用户包Bootstrap模式AJAX登录

有没有人已经使用Symfony 2和FOS User Bundle在Bootstrap模式中构建了一个登录表单?

这就是我现在拥有的:

SRC/Webibli/UserBundle /资源/配置/ service.yml

authentication_handler:
    class:        Webibli\UserBundle\Handler\AuthenticationHandler
    arguments:    [@router, @security.context, @fos_user.user_manager, @service_container]
Run Code Online (Sandbox Code Playgroud)

应用程序/配置/ security.yml

form_login:
    provider: fos_userbundle
    success_handler: authentication_handler
    failure_handler: authentication_handler
Run Code Online (Sandbox Code Playgroud)

SRC/Webibli/UserBundle /处理器/ AuthenticationHandler.php

<?php

namespace Webibli\UserBundle\Handler;

use Symfony\Component\Security\Http\Authentication\AuthenticationFailureHandlerInterface;
use Symfony\Component\Security\Http\Authentication\AuthenticationSuccessHandlerInterface;
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
use Symfony\Component\Routing\RouterInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\Routing\Router;
use Symfony\Component\Security\Core\SecurityContext;
use Symfony\Component\Security\Core\Exception\AuthenticationException;


class AuthenticationHandler implements AuthenticationSuccessHandlerInterface, AuthenticationFailureHandlerInterface
{

    protected $router;
    protected $security;
    protected $userManager;
    protected $service_container;

    public function __construct(RouterInterface $router, SecurityContext $security, $userManager, $service_container)
    {
        $this->router = $router;
        $this->security = $security; …
Run Code Online (Sandbox Code Playgroud)

php ajax symfony twitter-bootstrap fosuserbundle

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

Twig:在循环中设置变量,在循环外部使用它

我正在尝试driverid使用set,作为for driver in assigned.driver循环中的var 来供以后使用.看下面我在做什么:

{% for key, assigned in pgn %}
    <tr id="device-{{ assigned.id }}">
        <td>{{ assigned.imei }}</td>
        <td>{{ assigned.description }}</td>
        <td>
            {% for driver in assigned.driver %}
                {{ driver.driver.id }} {# check if driver.driver.id has values testing purposes - delete me #}
                {% set driverid = driver.driver.id %}

                {% if driver.driver.name != "" %}
                    {% if driver.driver.name %}
                        {{ driver.driver.name }}
                    {% else %}
                        -
                    {% endif %}
                {% endif %}
            {% …
Run Code Online (Sandbox Code Playgroud)

php symfony twig symfony-2.4

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