小编Ror*_*san的帖子

排除jQuery DataTables.net TableTools的最后一列

问题:在使用TableTools附加功能导出时,如何排除jQuery DataTables.net的最后一列?

细节

我正在用jQuery DataTables.net和TableTools附加组件初始化几个不同的表.它们都使用相同的初始化代码.

不同的表具有不同的列数.但是,所有表都有最后一列,这是一个带有按钮的"操作"列.使用TableTools导出时,它包含导出中此列的某些元素.我想排除所有表的TableTools导出的操作列.

我知道mColumns选项,但看起来您需要知道列数,这在我描述的场景中不起作用,所以请不要给我这样的答案:

"mColumns": [ 0, 1, 4 ]
Run Code Online (Sandbox Code Playgroud)

谢谢

jquery datatables jquery-datatables

0
推荐指数
1
解决办法
4410
查看次数

关注Maps API教程时出现"错误导致类片段错误"错误

我一直在关注Xamarin Maps API教程,并且一直遇到问题.其中最一致的是'Android.Views.InflateException'.我已经完成了绝对的信件,但却无法找到问题所在.我还回顾了关于这个问题的其他类似问题,但没有任何帮助 - 该项目根本不会构建.

MainActivity.cs:

using System;
using Android.App;
using Android.Content;
using Android.Runtime;
using Android.Views;
using Android.Widget;
using Android.OS;

namespace NewMapApp
{
    [Activity (Label = "NewMapApp", MainLauncher = true)]
    public class MainActivity : Activity
    {
        protected override void OnCreate (Bundle bundle)
        {
            base.OnCreate (bundle);

                    // this line causes the error
            SetContentView (Resource.Layout.Main);
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

Main.axml:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">
    <fragment
        android:id="@+id/map"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        class="com.google.android.gms.maps.MapFragment" />
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)

堆栈跟踪:

Android.Views.InflateException: Binary XML …
Run Code Online (Sandbox Code Playgroud)

android google-maps xamarin

0
推荐指数
1
解决办法
4789
查看次数

在字符串中查找子字符串

让我们说我有这些字符串:

My dog is young  

I have a _dog_ 

Dogs are fine
Run Code Online (Sandbox Code Playgroud)

我想有任何字符串dog唯一.这意味着我只想要返回第一行.另外两个,包含_我不想要的标记,或者最后有额外的标记s.

我尝试过这样的事情:

$('#side-categories a').each(function () {
    var href = $(this).attr("href");
    if (href.indexOf(table) >= 0) {
        $(this).css("color", "red");
        $(this).parents("ul").show().prev('.do').text('-');
    }
});
Run Code Online (Sandbox Code Playgroud)

但它也会返回_dog_Dogs

建议?

javascript jquery

0
推荐指数
1
解决办法
100
查看次数

在JQuery中使用JSON数组

我有一个宁静的Web服务http:// localhost:8080/CRUDWebAppMavenized/persons,输出一个json数组.我在jquery中使用AJAX,我想在我的HTML表中显示json数组.我不能让它显示在html表中.我将发布html,javascript代码和json数组代码.

index3.html HTML文件.用于在浏览器中显示学生信息.

<!DOCTYPE html>
<html>
    <head>
        <script type="text/javascript" src="engine.js"></script>
        <script type="text/javascript" src="http://code.jquery.com/jquery-1.11.0.min.js"></script>
    </head>
    <body>
        <table id="blogTable">
            <tr>
                <th>studentId</th>
                <th>firstname</th>
                <th>lastname</th>
                <th>yearLevel</th>
            </tr>
        </table>
    </body>
</html>
Run Code Online (Sandbox Code Playgroud)

engine.js(使用Jquery) AJAX调用然后将代码放在html文件的表标记中.

$(document).ready(function () {
    $.ajax({
        url: 'http://localhost:8080/CRUDWebAppMavenized/persons',
        type: 'GET',
        dataType: 'json',
        success: function (result) {
            var insert = '';
            $.each(result, function (index, item) {
                insert += '<tr><td>' + item.studentId + '</td><td>' + item.firstname + '</td><td>' + item.lastname + '</td><td>' + item.yearLevel + '</td></tr>';
            });
            $('#blogTable tr:last').after(insert);
        }
    });
});
Run Code Online (Sandbox Code Playgroud)

JSON数组 …

html javascript ajax jquery json

0
推荐指数
1
解决办法
717
查看次数

为什么在点击事件期间抓住<body>?使用.on()代替.click()

为什么第二个代码比第一个代码更好?为什么不.vote a直接抓住,而不是抓住body标签?我正在使用AJAX/JSON/PHP创建一个投票系统:

$('.vote a').click(function() {});

$('body').on('click','.vote a',function(){});
Run Code Online (Sandbox Code Playgroud)

javascript php ajax jquery json

0
推荐指数
1
解决办法
65
查看次数

为什么.attr()对$(this)起作用,但不对每个()的参数起作用?

我在node.js上使用cheerio(即jQuery服务器端)来解析网页.当试图获取href元素的属性时,我收到以下错误:

TypeError:Object#没有方法'attr'

我的代码是:

$('#commandes_pagination li a').each(function(index, element) {
    console.log(element.attr('href'));
});
Run Code Online (Sandbox Code Playgroud)

HTML是这样的:

<ul class="liste04" id="commandes_pagination">
    <li>        
        <a shape="rect" title="" href="/refonte/account/ajax/orderlist/1" class="page_num page_active" id="commandes_page-1">1</a>
    </li>
    <li>
        <a shape="rect" title="" href="/refonte/account/ajax/orderlist/2" class="page_num" id="commandes_page-2">2</a>
    </li>
</ul>
Run Code Online (Sandbox Code Playgroud)

我可以通过使用$(this).attr("href")而不是element.attr("href")但我无法弄清楚原因.任何解释都非常感谢!

javascript jquery cheerio

0
推荐指数
1
解决办法
1824
查看次数

在Javascript中删除子数组项

如何从id = 2JavaScript/jQuery中的以下数组中删除整个子数组项?

arr = [{
    "id": 1,
    "name": "Steve"
},{
    "id": 2,
    "name": "Martin"
},{
    "id": 3,
    "name": "Short"
}]
Run Code Online (Sandbox Code Playgroud)

我不确定如何使用grepsplice在这种情况下.

我想要的输出是:

newArr = [{
    "id": 1,
    "name": "Steve"
},{
    "id": 3,
    "name": "Short"
}]
Run Code Online (Sandbox Code Playgroud)

javascript arrays jquery

0
推荐指数
1
解决办法
4215
查看次数

单击&lt;td&gt;时获取父&lt;tr&gt;的值

我有以下表结构:

<tr class="tabrow" val="12345"> 
    <td class="clickable">abcde</td> 
    <td class="clickable">fghij</td> 
    <td class="clickable">2016-03-03 15:35:45</td> 
</tr>
Run Code Online (Sandbox Code Playgroud)

val当我单击任何字段时,我想要一种获取行的方法。到目前为止,我已经知道了:

$('.clickable').on('click', function() {
    evID = $(this).closest('tr').val();
    alert(evID);
})
Run Code Online (Sandbox Code Playgroud)

这行不通;它只是返回一个空白结果。我也试过了,这也行不通:

evID = $(this).parent().val();
Run Code Online (Sandbox Code Playgroud)

我究竟做错了什么?

jquery

0
推荐指数
1
解决办法
2万
查看次数

委托事件处理程序不起作用

这是我的HTML文件的一部分;

<script type="text/template" id="_profile">
    <div class="modalDialog">
        <div class="profile">
            <div class="box clearfix">
                <div class="box-header clearfix">
                    <span class="box-title l">{% trans 'PROFILE' %}</span>
                    <a href="#" style="margin-left: 10px;" id="profile_export" class="l"><span class="icon-download"></span>{% trans 'Profile Export' %}</a>
                    <div class="close-profile icon-cancel-circled r"></div>
                </div>
Run Code Online (Sandbox Code Playgroud)

$('.profile').on('click', '#profile_export', function (e) {
    e.preventDefault();
    $.get(root + '/profile/export/', function(resp) {
         // DO something
Run Code Online (Sandbox Code Playgroud)

我已经看了一些"jQuery中的事件委托"的例子,所以我写了上面的函数.可能是错的,因为当我点击它时,它什么也没做.它只是放在#当前URL的末尾.

谁能告诉我这里有什么问题?为什么当我点击#profile_export它不会触发"profile/export /"的请求?

谢谢

javascript jquery

0
推荐指数
1
解决办法
33
查看次数

on()不识别一个类

我正面临着一个问题on().这是我的代码:

<span class="add" id="id_foo" >add this stuff</span>
Run Code Online (Sandbox Code Playgroud)
$(".add").on('click', function() {
    $.post("/toto.com/add.php", { trainning: this.id }, function() {});
    $(this).html("Remove this stuff");
    $(this).removeClass("add").addClass("remove");
    //alert($(this).attr("class"));-->give the good class
});

$(".remove").on('click', function() {
    //doesn't work
    $.post("/toto.com/remove.php", { trainning: this.id }, function() {});
    $(this).html("add this stuff");
    $(this).removeClass("remove").addClass("add");
});
Run Code Online (Sandbox Code Playgroud)

类的选择器remove无法识别它,而当我单击带有add类的按钮时,类正在改变.你知道问题是什么吗?

谢谢您的帮助!

html javascript jquery

0
推荐指数
1
解决办法
76
查看次数