我想.load()
在我的页面中尝试一个bootstrap模式并立即显示它.下面是我编写的代码(当模态打开但不能关闭时,它不起作用)!
基本上.load()
当我点击一个团队名称(与班级.team
)时,我正在尝试一个模态中的玩家列表,我尝试了各种调用方式但$($this).empty()
没有成功.
这是我的功能:
$(function () {
$('.team').on('click', function () {
var target = $(this).data('target');
$('#results-modals').load('/team-players.html ' + target, function (response, status, xhr) {
if (status === "success") {
$(target).modal({ show: true });
}
});
});
});
Run Code Online (Sandbox Code Playgroud)
这是html锚点和示例模态:
<a class='team' data-toggle='modal' data-target='#20'>Real Madrid</a>
Run Code Online (Sandbox Code Playgroud)
外部文件team-players.html中保存的数据:
<div id='20' class="modal fade bs-example-modal-lg" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel" aria-hidden="true">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<p>Player 1: Ronaldo</p>
</div>
</div>
</div>
Run Code Online (Sandbox Code Playgroud) 我正在尝试编写一个MongoDB查询...
我的目的是通过country
排序依据检索玩家记录列表,rating
然后仅返回每个国家/地区的第n个评级玩家(因此评分最高,或评分最高等等).
我已经实现了第一部分:
db.getCollection('players').find( { event: 'open' }).sort({ country: 1, rating: -1 });
Run Code Online (Sandbox Code Playgroud)
以下是两个国家的样本,每个国家有三名玩家,按评级排序:
第一队:
{
"id" : 400041,
"name" : "Adams Michael",
"rating" : 2727,
"country" : "England",
"event" : "open"
},
{
"id" : 404853,
"name" : "McShane Luke J",
"rating" : 2671,
"country" : "England",
"event" : "open",
},
{
"id" : 400025,
"name" : "Short Nigel D",
"rating" : 2666,
"country" : "England",
"event" : "open"
} …
Run Code Online (Sandbox Code Playgroud) 我有一些关于Razor语法的一般性问题我一直在寻找一个正在研究的项目......
使用的主要助手之一是: @Html.InputFor
然后他们插入一些Lambda例如: @Html.InputFor(_ => _.User)
我的问题是,我如何使用这个助手(我无法通过谷歌搜索找到任何细节),即添加自定义CSS类等属性?
我应该使用更好的帮手吗?(我是Razor的新手)
今天我用谷歌搜索"解决"这个问题的生命!
我正在尝试使用服务帐户构建一个非常简单的Google Analytics数据请求控制台应用.我已在Google Developers Console中设置了所有必需的详细信息,但我收到以下错误消息:
An unhandled exception of type 'Google.Apis.Auth.OAuth2.Responses.TokenResponseException'
occurred in Google.Apis.dll
Additional information: Error:"invalid_grant", Description:"", Uri:""
Run Code Online (Sandbox Code Playgroud)
下面是我的控制台应用程序中的代码(隐藏了键):
using System.Security.Cryptography.X509Certificates;
using Google.Apis.Auth.OAuth2;
using Google.Apis.Services;
using Google.Apis.Analytics;
using Google.Apis.Analytics.v3;
using Google.Apis.Analytics.v3.Data;
using System;
namespace GoogleAnalyticsAPI
{
public class Program
{
public static void Main(string[] args)
{
string profileId = "12345678";
string serviceAccountEmail = "123456789abcdefghijklmnopq@developer.gserviceaccount.com";
X509Certificate2 certificate = new X509Certificate2(@"PrivateKey.p12", "mypassword", X509KeyStorageFlags.Exportable);
// Create credentials
ServiceAccountCredential credential = new ServiceAccountCredential(
new ServiceAccountCredential.Initializer(serviceAccountEmail)
{
Scopes = new[] { AnalyticsService.Scope.Analytics }
}.FromCertificate(certificate)); …
Run Code Online (Sandbox Code Playgroud) 我正在尝试从多个选择选项中提取文本,我已经设法使用以下代码拉出每个选项的值,但是当我使用时,.text()
我得到所有选项文本,而不是选择的那个.
$('#mySelects > .form-group select').each(function(){
alert($(this).val());
});
Run Code Online (Sandbox Code Playgroud)
以下是以下示例HTML
:
<div id="mySelects" class="panel-body">
<div class="form-group">
<select name="select-1" id="select-1" class="form-control">
<option selected="selected" value="0">Please Select</option>
<option value="11700599">Test Value 1</option>
</select>
</div>
<div class="form-group">
<select name="select-2" id="select-2" class="form-control">
<option selected="selected" value="0">Please Select</option>
<option value="11700467">Test Value 2</option>
</select>
</div>
Run Code Online (Sandbox Code Playgroud)
我当前的jQuery将返回:0, 0
我希望它返回:( "Please Select", "Please Select"
或选择任何文本)
我有跟随单个子数据结构,并希望通过子属性检索订单列表rating
:
players: {
360368: {
name: "Joe, Blogs",
rating: 1853
},
400017: {
name: "Bob, Dylan",
rating: 2597,
},
430013: {
name: "James, Dean",
rating: 2152,
}
}
Run Code Online (Sandbox Code Playgroud)
let ref = this.fb.ref('players');
ref.orderByChild("rating").limitToFirst(100).once("value", function(snapshot) {
console.log(snapshot.val());
});
Run Code Online (Sandbox Code Playgroud)
返回的结果似乎没有逻辑数字顺序.
最后,当我运行以下查询时,我得到了我期望的结果(看到10个玩家的评分为2597):
let ref = this.fb.ref('players');
ref.orderByChild("rating").equal(2597).limitToFirst(10).once("value", function(snapshot) {
console.log(snapshot.val());
});
Run Code Online (Sandbox Code Playgroud)
看来数据是由对象键返回的.如何确保退货,订购rating
?