小编Ani*_*pta的帖子

要求使用shim配置的原因和时间

我从这里读apirequirejs文件

requirejs.config({
    shim: {
        'backbone': {
            //These script dependencies should be loaded before loading
            //backbone.js
            deps: ['underscore', 'jquery'],
            //Once loaded, use the global 'Backbone' as the
            //module value.
            exports: 'Backbone'
        },
        'underscore': {
            exports: '_'
        },
        'foo': {
            deps: ['bar'],
            exports: 'Foo',
            init: function (bar) {
                //Using a function allows you to call noConflict for
                //libraries that support it, and do other cleanup.
                //However, plugins for those libraries may still want
                //a global. "this" for the …
Run Code Online (Sandbox Code Playgroud)

javascript amd requirejs

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

在symfony2 sonata admin bundle中设置默认值

如何在sonata admin bundle中设置默认值,configureFormFields方法中缺少data选项

protected function configureFormFields(FormMapper $formMapper)
{
    $formMapper
        ->add('name', null, array('required' => true, 'data' => "my default value"))
    ;
}
Run Code Online (Sandbox Code Playgroud)

如何使用data属性在字段内设置默认值???

symfony symfony-sonata

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

为什么 HMAC sha256 在 PHP 和 Javascript 上返回不同的值

我正在尝试使用 CryptoJS 在 Javascript 中构建一个 HMAC SHA256 字符串,我现有的代码是使用 Akamai 库用 PHP 编写的。

在某些情况下,与 PHP 相比,我得到了不同的结果,我无法理解为什么它会给我不同的结果

    /* 
       <php> Using native hash_hmac
       Generating key by concatenating char 
    */ 

      $signature1 = hash_hmac('SHA256', "st=1453362060~exp=1453363260~acl=/*", chr(63));
      $signature2 = hash_hmac('SHA256', "st=1453362060~exp=1453363260~acl=/*", chr(63) . chr(23));
      $signature3 = hash_hmac('SHA256', "st=1453362060~exp=1453363260~acl=/*", chr(63) . chr(23) . chr(253));

    /*
       here is result from php
       signature1 : 3e086bb48ab9aafa85661f9ce1b7dac49befddf117ce2a42d93c92b6abe513ce ( matched: same as JavaScript)
       signature2 : 3667dd414a50f68f7ce083e540f27f68f7d0f18617b1fb1e4788bffeaeab59f6( matched: same as JavaScript)
       signature3 : dd5a20041661046fdee871c8b9e77b3190fbbf85937c098090a1d524719b6aa9 ( not matched: diff from JavaScript)
    */


    /* 
       <JavaScript> …
Run Code Online (Sandbox Code Playgroud)

javascript php sha256 hmac cryptojs

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

knockoutjs如何获取所选的选项arrayObject

我想获得所选的选项对象

    <select data-bind="options: availableCountries,
                       value: selectedCountry, event: { select: onSelect}"></select>


<script type="text/javascript">
    // Constructor for an object with two properties
    var Country = function(name, population) {
        this.countryName = name;
        this.countryPopulation = population;   
    };       

    var viewModel = {
        availableCountries : ko.observableArray([
            new Country("UK", 65000000),
            new Country("USA", 320000000),
            new Country("Sweden", 29000000)
        ]),
        selectedCountry : ko.observable(), // Nothing selected by default
        onSelect: function(){
              console.log(viewModel.selectedCountry)
              // it is showing just an country name and what i what is whole object
              // e.g. { "UK", …
Run Code Online (Sandbox Code Playgroud)

knockout-2.0 knockout.js

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

使用webpack在react组件中实现jwplayer的正确方法(react-starter-kit)

我正在使用jwpalyer制作VideoPlayer反应组件,我正在使用webpack es6来加载模块webpack支持npm模块加载并且jwplayer没有npm

所以我试图使用es6 import包含jwplayer.js,但它给了我错误ReferenceError:window未定义

所以任何人都可以帮我正确设置webpack的jwplayer

  import React, { PropTypes, Component } from 'react';
  import $ from 'jquery';
  import Player from "./lib/jwplayer/jwplayer.js";
  import styles from './VideoPayer.css';
  import withStyles from '../../decorators/withStyles';
  import Link from '../Link';

  @withStyles(styles)
  class VideoPlayer extends Component {

    static propTypes = {
      className: PropTypes.string,
    };

    static defaultProps = {
      file: '',
      image: ''
    };

    constructor(props) {
      super(props);
      this.playerElement = document.getElementById('my-player');
    }


    componentDidMount() {
      if(this.props.file) {
        this.setupPlayer();
      }
    }

    componentDidUpdate() {
      if(this.props.file) {
        this.setupPlayer();
      }
    }

    componentWillUnmount() {
       Player().remove(this.playerElement);
    } …
Run Code Online (Sandbox Code Playgroud)

jwplayer reactjs jwplayer6 webpack es6-module-loader

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

symfony 2 sonataAdminBundle覆盖模板

我们如何覆盖单个Admin类的奏鸣曲包布局,就像我已经创建了3个Admin类userAdmin,productAdmin,ticketAdmin现在我想覆盖ticketAdmin编辑操作并编辑模板并在那里添加一些额外的代码.

symfony sonata-admin

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