所以我正在使用简写的javascript if/ else语句(我在某处读到它们被称为三元语句?)
this.dragHandle.hasClass('handle-low') ? direction = "left" : direction = "right"
这很好用,但如果以后我想只使用一个速记if,没有这个else部分会怎样.喜欢:
direction == "right" ? slideOffset += $(".range-slide").width()
这有可能吗?
我有一个双列布局,左边是侧边栏,右边是内容.
所以我将侧边栏向左浮动,并将右边的内容放在边缘.一切都很好,很好......
直到内容的子元素应用了清晰,它才会跳到侧边栏下方.
有没有办法让子元素只在其父容器中浮动和清除?
由于图片价值1000字,这里是一个JSFiddle:
我目前有一个功能,可以检测鼠标输入的方向.它返回每个部分的整数(0-3),如下所示.

我试图找出如何更改此函数以基于此插图生成输出:

基本上,我只想弄清楚用户是从左边还是右边输入图像.我曾尝试过几次试错,但我对这种类型的数学并不擅长.
确定方向的功能是:
function determineDirection($el, pos){
var w = $el.width(),
h = $el.height(),
x = (pos.x - $el.offset().left - (w/2)) * (w > h ? (h/w) : 1),
y = (pos.y - $el.offset().top - (h/2)) * (h > w ? (w/h) : 1);
return Math.round((((Math.atan2(y,x) * (180/Math.PI)) + 180)) / 90 + 3) % 4;
}
Run Code Online (Sandbox Code Playgroud)
pos对象在哪里:{x: e.pageX, y: e.pageY},$el是包含目标元素的jQuery对象.
我根据知识库文章激活了ImageMagick扩展
基本上,将此行添加到php.ini:
open_basedir = /nfs:/tmp:/usr/local:/etc/apache2/gs-bin:/usr/bin/convert
Run Code Online (Sandbox Code Playgroud)
但是,这似乎不起作用.
这个脚本输出版本号就好了:
$IM_version=shell_exec("/usr/bin/convert -version");
echo $IM_version;
Run Code Online (Sandbox Code Playgroud)
但是,当我尝试使用Imagick该类时,我收到错误.
try
{
/*** a new imagick object ***/
$im = new Imagick();
/*** Create a red rectangle ***/
$im->newImage( 200, 100, "red", "png" );
/*** write image to disk ***/
$im->writeImage( '/tmp/rectangle.png' );
echo 'Image Created';
}
catch(Exception $e)
{
echo $e->getMessage();
}
Run Code Online (Sandbox Code Playgroud)
错误:
Fatal error: Class 'Imagick' not found in /xxxxxxxxxxxxxxx/html/mt.php on line 8
Run Code Online (Sandbox Code Playgroud)
任何想法我做错了什么或下一步的故障排除是什么?
我已经联系了MediaTemple支持,他们只是说"抱歉,但因为脚本输出的版本号证明它已安装"
我有一个手机包装的sencha touch(v1.1.1)应用程序,它有几个商店和一个列表.
以"User1"身份登录后出现此问题,然后注销并以"User2"身份重新登录.该列表不会使用商店代理提取的新帐户数据进行刷新.
我目前正在尝试调用.refresh()的List本身,它根据文档也将导致实体店刷新其数据(虽然,我手动这样做,前手反正)
var sL = Ext.getCmp('AccountsList');
sL.refresh();
sL.scroller.scrollTo({x:0,y:0});
Run Code Online (Sandbox Code Playgroud)
我们也试过.sync()没有结果的商店.
Ext.getStore('AccountsTransfersTo').sync();
Ext.getStore('AccountsTransfersFrom').sync();
Ext.getStore('AccountsStore').sync();
Run Code Online (Sandbox Code Playgroud)
知道问题是什么,或者有没有人碰到类似的东西?
HTML
<input id="formloginusername" type="text" name="username" placeholder="Username" value="Pre-filled-from-database"></input>
Run Code Online (Sandbox Code Playgroud)
JS:
$(document).ready(function() {
$("#formloginusername").focus();
});
Run Code Online (Sandbox Code Playgroud)
Problem:
突出显示"预填充数据库"文本.我只希望光标在字段中显示,就像用户在填充文本后点击它一样.
谢谢!
因此,我正在创建一个基本的虚荣URL系统,我可以http://myURL.com/v/some-text从数据库中获取项目,并根据客户端是否为移动/桌面和其他功能重定向到特定的URL.
我通常构建Facebook应用程序,因此在桌面的情况下,它们将被重定向到Facebook URL,否则在移动设备上我可以使用普通路由.
有没有办法从服务器端的Iron Router重定向到外部网站?
this.route('vanity',{
path: '/v/:vanity',
data: function(){
var vanity = Vanity.findOne({slug:this.params.vanity});
// mobile / desktop detection
if(vanity){
if(mobile){
// Redirect to vanity mobile link
}else{
// Redirect to vanity desktop link
}
}else{
Router.go('/');
}
}
});
Run Code Online (Sandbox Code Playgroud) 我一直在以各种可能的角度看待这个问题而我无法理解它,也许你们可以提供帮助.我运行此查询以获取我朋友的家乡和位置:
SELECT uid, name, timezone, hometown_location, current_location
FROM user WHERE uid IN ( SELECT uid2 FROM friend WHERE uid1 = me() )
Run Code Online (Sandbox Code Playgroud)
并且hometown_location和current_location 始终为 NULL,即使它们不应该是NULL.使用像/ me/friends这样的东西?fields = hometown,location,...有相同的结果.
另外,查询我自己的hometown_location和current_location是否正常工作.这让我觉得我没有权限访问我朋友的家乡和位置......但是如果是这样的话,不应该提出错误吗?
不过,我的应用程序具有相同的权限:user_about_me,friends_about_me,user_hometown,friends_hometown,user_location和friends_location,所以我不认为这是问题所在.
如果我访问http://developers.facebook.com/docs/reference/api/并点击https://graph.facebook.com/me/friends?access_token= ...链接,我追加&fields =名字,故乡,它的工作原理,所以我知道它可以做到.
知道我能做错什么吗?
非常感谢!
曼努埃尔
我从Web服务中获取日期,它们看起来像这样:
/Date(1310187160270+1200)/
我如何将其转换为javascript中的日期对象?
我已经google了一下,找不到合适的答案 - 这可能部分是由于我不确定这种类型的日期对象被调用的事实 - 所以如果有人能够阐明这一点,那么不胜感激.
<div>
<h3>Heading one</h3>
<h3>Heading two</h3>
<h4>heading caption</h4>
<h3>Heading three</h3>
</div>?
Run Code Online (Sandbox Code Playgroud)
我想在jQuery选择中获取元素的位置,而不是它在DOM中的索引.
目前,如果我alert($("h3").eq(2).index());得到'3' - 我想要'2'.
我们有一个用于DOM元素的setAttribute方法.
https://developer.mozilla.org/en-US/docs/DOM/element.setAttribute
它与使用下面有什么不同?
domElement.propName = value
Run Code Online (Sandbox Code Playgroud)
两种方法都有任何好处吗?
谢谢.
全新的javascript!这有效,但我还有很多工作要做,如果有更简洁的方法可以做到这一点会很棒.如果需要,请打开使用jquery :)
(堆栈希望我在提交之前写更多内容,但我不知道还有什么要说的)
<script>
function apply(){
var backerPrediction1 = document.getElementById("backer-prediction-1").value;
var backerPrediction2 = document.getElementById("backer-prediction-2").value;
var backerPrediction3 = document.getElementById("backer-prediction-3").value;
var backerPrediction4 = document.getElementById("backer-prediction-4").value;
var backerPrediction5 = document.getElementById("backer-prediction-5").value;
var backerPrediction6 = document.getElementById("backer-prediction-6").value;
var backerPrediction7 = document.getElementById("backer-prediction-7").value;
var backerPrediction8 = document.getElementById("backer-prediction-8").value;
var backerPrediction9 = document.getElementById("backer-prediction-9").value;
var backerPrediction10 = document.getElementById("backer-prediction-10").value;
var backerPrediction11 = document.getElementById("backer-prediction-11").value;
var backerPrediction12= document.getElementById("backer-prediction-12").value;
var backerPrediction13 = document.getElementById("backer-prediction-13").value;
var backerPrediction14 = document.getElementById("backer-prediction-14").value;
var backerPrediction15 = document.getElementById("backer-prediction-15").value;
var backerPrediction16 = document.getElementById("backer-prediction-16").value;
var backerPrediction17 = document.getElementById("backer-prediction-17").value;
var backerPrediction18 = document.getElementById("backer-prediction-18").value;
var backerPrediction19 = …Run Code Online (Sandbox Code Playgroud) javascript ×8
jquery ×3
html ×2
angle ×1
css ×1
css-float ×1
datetime ×1
dom ×1
extjs ×1
facebook ×1
facebook-fql ×1
focus ×1
highlight ×1
if-statement ×1
imagemagick ×1
iron-router ×1
json ×1
math ×1
mediatemple ×1
meteor ×1
php ×1
sencha-touch ×1
shorthand ×1
shorthand-if ×1
web-services ×1