var conversations = new Array();
jQuery('.CChatWindow').each(function(){
if (jQuery(this).is(":visible") && jQuery(this).attr("data-conversationid") != 0) {
alert(jQuery(this).attr("data-conversationid")); // returns 1 and 2
conversations.push = (jQuery(this).attr("data-conversationid"));
}
});
alert(conversations); // returns an empty string
Run Code Online (Sandbox Code Playgroud)
我的代码有问题吗?array.push似乎不起作用.谢谢!
我正在使用jQuery Tablesorter 2.0(http://tablesorter.com/docs/).排序数字工作正常,但只要我添加
number_format($count);
Run Code Online (Sandbox Code Playgroud)
在我的代码中,排序不再起作用了.它的排序如下:
810,208 - > 7,671,897 - > 2,329,439
代替
7,671,897 - > 2,329,439 - > 810,208
有任何解决这个问题的方法吗?我需要逗号分隔数字以便更好地阅读.谢谢
我正在搜索一个函数来剪切以下字符串并获取所有内容BEFORE和AFTER
I need this part<!-- more -->and also this part
Run Code Online (Sandbox Code Playgroud)
结果应该是
$result[0] = "I need this part"
$result[1] = "and also this part"
Run Code Online (Sandbox Code Playgroud)
感谢任何帮助!
class Test {
public function __construct() {
self::runTest();
Test::runTest();
}
public static function runTest() {
echo "Test running";
}
}
// echoes 2x "Test running"
new Test();
Run Code Online (Sandbox Code Playgroud)
有什么区别self::runTest()和Test::runTest()?如果是这样,我应该使用哪一个?
self::runTest()在类中和Test::runTest()类外调用方法时?
我想突出显示句子中的单个字符串。替换应该使用不区分大小写的字符(如foo句子中的字符串My Foo bar)。
这对我来说没有问题:
var regEx = new RegExp(this._searchString, "gi");
var label = $(item).text();
label = label.replace(regEx, '<span style="font-weight:bold;">' + this._searchString + '</span>');
$(item).html(label);
Run Code Online (Sandbox Code Playgroud)
这里的问题是:如果我搜索和替换foo的My Foo bar,其结果将是
My <span style="font-weight:bold;">foo</span> bar,但我想要的是My <span style="font-weight:bold;">Foo</span> bar。
所以搜索应该忽略区分大小写,而不是替换。知道怎么做吗?我看到的唯一方法是首先检查字符串是否包含搜索的字符串,提取它(区分大小写),修改它并将其放回字符串中。但这对我来说似乎太多了,不是吗?
我无法找到任何文档,我可以找到一个代码示例来接收视频的喜欢和不喜欢.这是我目前的代码:
$videoId = 'AyJl2NyQ0hI';
$videoEntry = $yt->getVideoEntry($videoId);
echo "Views: <strong>".$videoEntry->getVideoViewCount()."</strong><br />";
Run Code Online (Sandbox Code Playgroud)
它工作得很好,但谁得到喜欢/不喜欢?谢谢.
所以我有一个奇怪的问题,我现在无法解决。
房间游戏片段
@Override
public void onAttach(Activity activity) {
super.onAttach(activity);
roomActivity = (RoomActivity) activity;
gameTabContainerView = (LinearLayout) roomActivity.findViewById(R.id.game_tab_container); // findViewById returns null
// NullPointerException
gameTabContainerView.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
}
});
}
Run Code Online (Sandbox Code Playgroud)
打开包含片段的活动时,这完全正常。但问题是:如果我将 Activity 保持打开状态,将应用程序置于后台(通过单击主页按钮),使用其他应用程序,然后在一段时间后再次打开我的应用程序,我会收到 NullPointerException,因为findViewById现在返回 null。我怎样才能防止这种情况?Activity 是否从堆栈中移除,从而导致异常?我知道我可以只检查null,但我需要onClickListener,即使我在后台返回应用程序时也是如此。
我有问题将我的非www网址重定向到www和https.
我想要的是:
http://domain.com
http://www.domain.com
https://domain.com
Run Code Online (Sandbox Code Playgroud)
应该重定向到https://www.domain.com.
http://api.domain.com
Run Code Online (Sandbox Code Playgroud)
应该重定向到 https://api.domain.com
我有domain.com和api.domain.com的seperata ssl密钥.api.domain.com的SSL设置通过node.js应用程序处理.此外,domain.com使用根文档,api.domain.com使用proxy_pass到端口1336上的node.js应用程序.
我尝试了什么:
# route non ssl api to ssl
server {
listen 80;
server_name api.domain.com;
return 301 https://api.domain.com;
}
# main ssl route for api.domain.com
server {
listen 443 ssl;
server_name api.domain.com;
location / {
proxy_pass https://localhost:1337;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
}
# route non ssl to www ssl
server {
listen 80;
server_name www.domain.com domain.com;
return 301 …Run Code Online (Sandbox Code Playgroud) DatabaseReference ridesRef = database.getReference("rides");
ridesRef.equalTo(from).orderByChild("from").addListenerForSingleValueEvent(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
Log.i(TAG, "dataSnapshot.getChildrenCount(): " + dataSnapshot.getChildrenCount());
if (dataSnapshot.getChildrenCount() > 0) {
ArrayList<Ride> value = (ArrayList<Ride>) dataSnapshot.getValue();
Log.i(TAG, value.toString());
for (Ride r : value) { // error occurs here
Log.i(TAG, "r.getTime:" + r.getTime());
Log.i(TAG, "getFrom:" + r.getFrom());
}
}
}
});
Run Code Online (Sandbox Code Playgroud)
日志输出是:
09-02 18:08:25.070 23651-23651 I/RidesFragment:dataSnapshot.getChildrenCount():1
09-02 18:08:25.070 23651-23651 I/RidesFragment:[{to = Hackerscher Markt,userID = 0,time = 1472831718565,regular = false,price = 0,chosenUserID = 0,active = true,places = 1, from = …
我的活动中有多个视图,包括2个垂直(1行)RecyclerViews.我禁用了RecyclerViews上的滚动,setNestedScrollingEnabled(false)只想让整个活动可滚动.这不符合预期.触摸RecyclerViews(我的AppBarLayout)外部的视图会触发滚动,但是当我尝试在其中一个内滚动时RecyclerViews,它就不再起作用了.我是否必须将触摸事件传递给我的主视图,还是有其他解决方案?
我的布局看起来像这样(剥离):
<android.support.design.widget.AppBarLayout>
<android.support.design.widget.CollapsingToolbarLayout>
<RelativeLayout>
<ImageView>
<LinearLayout>
<TextView />
<TextView />
</LinearLayout>
</RelativeLayout>
<android.support.v7.widget.Toolbar />
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1">
<Button />
<android.support.v7.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clipToPadding="false"
android:scrollbars="none" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1">
<Button />
<android.support.v7.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clipToPadding="false"
android:scrollbars="none" />
</LinearLayout>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
编辑:刚刚添加了一张图片.触摸红色部分会按预期滚动整个活动,但触摸蓝色部分不会滚动任何内容.
