我正在使用requirejs + jquery,我想知道是否有一种聪明的方法可以使jQuery插件与require一起使用.
例如,我正在使用jQuery-cookie.如果我理解正确,我可以创建一个名为jquery-cookie.js的文件,并在里面做
define(["jquery"], // Require jquery
function($){
// Put here the plugin code.
// No need to return anything as we are augmenting the jQuery object
});
requirejs.config( {
"shim": {
"jquery-cookie" : ["jquery"]
}
} );
Run Code Online (Sandbox Code Playgroud)
我想知道我是否可以像jQuery那样做,这是这样的:
if ( typeof define === "function" && define.amd && define.amd.jQuery ) {
define( "jquery", [], function () { return jQuery; } );
}
Run Code Online (Sandbox Code Playgroud)
或者,这是使jQuery插件与requirejs或任何amd兼容的唯一方法
我正在使用express.js,我需要知道发起呼叫的域名.这是简单的代码
app.get(
'/verify_license_key.json',
function( req, res ) {
// do something
Run Code Online (Sandbox Code Playgroud)
我要如何从域req或res对象?我的意思是我需要知道api是否被somesite.com或someothersite.com调用.我试着做两者的console.dir req和res,但我还是不知道从那里,也可以参考文档,但它给了我没有帮助.
我需要为一个setTimeout()内部有一个调用的函数编写一个测试,但是我找不到我应该怎么做.
这是功能
// Disables all submit buttons after a submit button is pressed.
var block_all_submit_and_ajax = function( el ) {
// Clone the clicked button, we need to know what button has been clicked so that we can react accordingly
var $clone = $( el ).clone();
// Change the type to hidden
$clone.attr( 'type', 'hidden' );
// Put the hidden button in the DOM
$( el ).after( $clone );
// Disable all submit button. I use setTimeout otherwise …Run Code Online (Sandbox Code Playgroud) 目前在我们的插件中,我们通过设置选中复选框
<input type="checkbox" checked="checked" />
Run Code Online (Sandbox Code Playgroud)
这是为了保持xhtml兼容性.我更习惯将托运设置为财产
<input type="checkbox" checked />
Run Code Online (Sandbox Code Playgroud)
在html5中进行的正确方法是什么?我们还应该关心xhtml的兼容性吗?
是否有一个jQuery插件自动创建一个下拉年选择器(这是一个"选择"元素,包含从当前开始并可追溯到给定年份的所有年份)?
我不需要日/月(否则我已经使用了日期选择器),我只需要一年!
提前致谢
我正在管理一个来自Alfresco Properties的日期,并且在指定的时间(2010年7月13日00:00:00 CEST 2010),我需要将其转换为Java日期......我环顾四周,发现数百万各种字符串到日期转换表单的帖子以及此页面,所以我试过这样的事情:
private static final DateFormat alfrescoDateFormat = new SimpleDateFormat("EEE MMM dd HH:mm:ss zzz yyyy");
Date dataRispostaDate = alfrescoDateFormat.parse(dataRisposta);
Run Code Online (Sandbox Code Playgroud)
但它引发了一个例外.(例外是(SSollevata un'eccezione durante la gestione della data:java.text.ParseException:Unparseable date:"Tue Jul 13 00:00:00 CEST 2011").
我发布完整的代码:
try {
QName currDocTypeQName = (QName) nodeService.getType(doc);
log.error("QName:["+currDocTypeQName.toString()+"]");
if (currDocTypeQName != null) {
String codAtto = AlfrescoConstants.getCodAttoFromQName(currDocTypeQName.toString());
log.error("codAtto:["+codAtto+"]");
if (codAtto.equals(AlfrescoConstants.COD_IQT)){
List<ChildAssociationRef> risposteAssociate = nodeService.getChildAssocs(doc, AlfrescoConstants.QN_RISPOSTEASSOCIATE, RegexQNamePattern.MATCH_ALL);
for (ChildAssociationRef childAssocRef : risposteAssociate) {
// Vado a prendere il nodo
NodeRef risposta = childAssocRef.getChildRef();
String …Run Code Online (Sandbox Code Playgroud) 我正在编写一个wordpress插件,其中CSS是以dinamically方式编译的,因此我已经实现了各种策略来缓存它.截至目前,缓存的首选是APC,如果安装的话.
这是我正在检查它
$is_apc_installed = function_exists( 'apc_store' )
&& function_exists( 'apc_fetch' )
&& ini_get( 'apc.enabled' );
$sapi_type = php_sapi_name();
if (substr($sapi_type, 0, 3) === 'cgi') {
$is_apc_installed = false;
}
Run Code Online (Sandbox Code Playgroud)
但在某些安装中我仍然得到apc_fetch()总是返回false.我还应该检查以确保APC正常工作?
我正在使用flexslider插件,我想知道是否有一个简单的方法(除了更改插件的核心,这是我将要做的,如果我没有找到一个简单的答案)显示下一张幻灯片当您单击当前幻灯片时.我像这样设置了flexslider
$('.flexslider').flexslider({
directionNav : false,
slideshow: false,
animation: "slide",
controlsContainer: ".flex-container"
});
Run Code Online (Sandbox Code Playgroud)
我禁用了Prev/Next命令,因为我不喜欢它们.我该怎么办?
我开始使用symfony 2,但我想使用小胡子作为模板语言而不是Twig或PHP.我不想使用胡子,因为它完全没有逻辑,因为如果我决定处理模板客户端的渲染,我也可以在javascript中使用它.
怎么做?
我有一个调用geolocator的函数,我不知道如何测试这个函数.我试过监视地理定位器并返回假数据但没有成功,原来的功能仍然使用,所以我不得不等待,我不能使用模拟数据.
// this doesn't work
var navigator_spy = spyOn( navigator.geolocation, 'getCurrentPosition' ).andReturn( {
coords : {
latitude : 63,
longitude : 143
}
} );
Run Code Online (Sandbox Code Playgroud)
我怎样才能做到这一点?
javascript ×5
jquery ×4
jasmine ×2
php ×2
unit-testing ×2
alfresco ×1
apc ×1
date-parsing ×1
express ×1
flexslider ×1
geolocation ×1
html ×1
html5 ×1
java ×1
mustache ×1
node.js ×1
requirejs ×1
settimeout ×1
symfony ×1
xhtml ×1