define和之间的区别是什么require?我何时应该使用它们?我已经在Stack Overflow上阅读了不同的答案,但我仍然无法理解.
例如,如果打开main.js(配置文件需要指向),有什么区别?
define(["jquery"], function($) {
do something with $
});
require(["jquery"], function($) {
do something with $
});
Run Code Online (Sandbox Code Playgroud)
为$/jQ保证被加载并在这两个准备好了吗?
我是Angular的新手,只是掌握了AngularUI Router框架.我有一个html页面,其中包含一个问题列表(每个问题都需要自己的URL)和一个结果页面.
我创建了一个快速剥离的plunker(包含所有文件)来演示问题:
http://plnkr.co/edit/QErnkddmWB0JgendbOiV?p=preview
对于SO ref:
app.js
angular.module('foo', ['ui.router'])
.config(function($stateProvider, $urlRouterProvider) {
$urlRouterProvider.otherwise('/q1');
$stateProvider
.state('question', {
url: '/:questionID',
templateUrl: 'questions.html',
controller: 'questionsCtrl'
})
.state('results', {
url: '/results',
templateUrl: 'results.html'
})
})
.controller('questionsCtrl', function($scope, $stateParams) {
$scope.questionID = $stateParams.questionID;
$scope.scotches = [
{
name: 'Macallan 12',
price: 50
},
{
name: 'Chivas Regal Royal Salute',
price: 10000
}
];
});
Run Code Online (Sandbox Code Playgroud)
基本上由于某些未知原因(对我而言),我必须单击两次" 结果 "链接才能在第一次点击时出现在我眼中.
有谁知道为什么会这样?
一个.
我正在努力让我的头发试图让iscroll 4与jQuery Mobile合作.
一切正常,我禁用JQM ajax默认导航,但我想保留这个.
我的问题是我无法解决如何成功调用/绑定iscroll所以它适用于需要它们的页面.我试过pageinit()和pagecreate()无济于事.
任何指针都非常赞赏.
一个.
我试图找出如果某个文本框不为空(如包含某些东西,可能是任何东西)的方法
这是我的代码(似乎不起作用)
if ( !($('#edit-sPostalCode').attr('val','')) ) {
stuff here
}
Run Code Online (Sandbox Code Playgroud)
我错过了什么?
我正在制作一个小型SVG小部件,针对具有固定页脚的iphone.
问题是我想使用本机捏和缩放,只影响这个固定页脚的所有内容.
但是,如果我使用,我不能使用原生捏和缩放
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, minimum-scale=1.0, maximum-scale=1.0">
Run Code Online (Sandbox Code Playgroud)
我认为需要哪些标准化移动设备的320px宽度?
我的想法是(我敢说)一个iframe用于固定页脚上方的捏/变焦东西,但你需要2个手指来滚动iframe,99%的用户不会知道(除非有一个简单的js修复? )
任何帮助/指导非常感谢.
阿迪.
我试图在我的 htaccess 文件中设置一些缓存控制选项。
目前它看起来像这样:
<FilesMatch "\.(flv|gif|jpg|jpeg|png|ico|swf|css|js|html|pdf)$">
Header set Cache-Control "max-age=2592000, public, must-revalidate"
Header unset ETag
FileETag None
</FilesMatch>
Run Code Online (Sandbox Code Playgroud)
但是我读到(并想添加)标题未设置上次修改时间,所以它会是这样的:
<FilesMatch "\.(flv|gif|jpg|jpeg|png|ico|swf|css|js|html|pdf)$">
Header set Cache-Control "max-age=2592000, public, must-revalidate"
Header unset Last-Modified
Header unset ETag
FileETag None
</FilesMatch>
Run Code Online (Sandbox Code Playgroud)
然而,使用这个(根据 Firebug)根本不会从缓存中加载任何内容(而第一种技术会加载所有内容)
难道我做错了什么?语法似乎是正确的。
A。
刚刚开始一个新的HTML5项目并使用modernizr.js
我注意到在modernizr docs页面上它说你可以使用以下内容:
Modernizr.load([
{
load: '//ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.js',
complete: function () {
if ( !window.jQuery ) {
Modernizr.load('js/libs/jquery-1.6.1.min.js');
}
}
}
]);
Run Code Online (Sandbox Code Playgroud)
所以在我的HTML中我有这个:
<script src="scripts/modernizr-2.0.6.js"></script>
<script>
Modernizr.load([
{
load: 'https://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js',
complete: function () {
if ( !window.jQuery ) {
Modernizr.load('scripts/jquery-1.6.1.min.js');
}
}
}
]);
</script>
Run Code Online (Sandbox Code Playgroud)
但看着萤火虫,没有jquery正在装载.
我错过了一些明显的东西吗?
干杯,阿迪
我使用伟大的异步脚本加载器yepnope.js(在Modernizr2中).
我的问题是,将latset Google Analtics异步代码合并到yepnope(如果有的话)的最佳方法是什么?
谷歌建议使用实际的分析代码:
<html>
<head>
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-XXXXX-X']);
_gaq.push(['_trackPageview']);
</script>
</head>
<body>
<p>Page Content</p>
<script src="some_random_script.js"></script>
<p>Page Content</p>
<script type="text/javascript"> (function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
但在Modernizrs文档中,他们提到了这一点:
// Give Modernizr.load a string, an object, or an array of strings and objects
Modernizr.load([
// Presentational …Run Code Online (Sandbox Code Playgroud) 我有一个新任务要做,我不确定使用jQuery处理它的最佳方法.
基本上,客户需要"x"数量的文本框(数量),每个文本框都有一个加号/减号按钮/图标,当您点击每一个时,所有相关字段都会更新.
例如(如果页面中有3个选项)
qty [0] + -
qty [0] + -
qty [0] + -
以上所有[0]的总和
我经常使用jQuery,但我不知道从哪里开始.
任何建议将不胜感激.
阿迪.
我正在努力让我的头发试图让iscroll 4与jQuery Mobile合作.
如果我禁用JQM ajax默认导航这一切都工作正常,但我想保留这个.
我的问题是我无法解决如何成功调用/绑定iscroll所以它适用于需要它们的页面.我试过pageinit()和pagecreate()无济于事.
可以在这里找到一个基本的例子:http: //bit.ly/ngXkNR
任何指针都非常赞赏.
一个.
jquery ×6
iscroll4 ×2
javascript ×2
modernizr ×2
.htaccess ×1
angular-ui ×1
angularjs ×1
caching ×1
fixed ×1
jqtouch ×1
requirejs ×1
sencha-touch ×1
static ×1
sum ×1
yepnope ×1