$(document).ready(function () {
var otable = $('#tbl-resources').dataTable(
{
bJQueryUI: false, bFilter: true, bPaginate: true, bSort: false, bInfo: true,
"oLanguage": { "sSearch": "Click on column to sort / Search all columns for:" }
, "sPaginationType": "simple_numbers", "bAutoWidth": false,
"sDom": '<"row view-filter" <"col-sm-6"<"#ddl-category">><"col-sm-6"<"pull-right"f>>>t<"row view-pager"<"col-sm-7"<"pull-left"l><"pull-right"i>><"col-sm-5"<"pull-right"p>>>',
"aoColumns": [
null,
null,
null,
{ "width": "40%" }
],
"buttons": [
{
extend: 'collection',
text: 'Select Resource Category',
"fnClick": function (nButton, oConfig, oFlash) {
alert('Mouse click');
} } ]
}); $label = $('<label/>').text('Resource Category:').appendTo('#ddl-category')
$label.append("&nbsp;&nbsp;&nbsp;&nbsp;");
//insert the select and some options
$select = $('<select/>', { 'class': 'form-control' }).appendTo('#ddl-category')
@foreach (var item in Model.ResourceCategories)
{
<Text> $('<option/>').val('@item.Value').text('@item.Text').appendTo($select); </Text> }
otable.$(".editResource").on('click', function () {
var category = $('#ddl-category :selected').val();
alert(category);
var overridden = $(this).data('overridden');
var resourceId = $(this).attr('data-resourceId');
$.ajax({
url: '@Url.Action("EditResource", "Correspondent")',
type: "POST",
data: { selectedId: resourceId, selectedCategory: category, IsOverriddenResource: overridden },
}).success(function (result) {
$('#div-edit-modal').html(result);
$('#edit-modal').modal('show');
});
}); });

My last column in Datatable is link, but only work on the first page, whenever I changed the page number or number shown on page the links were not working.

Solution: Delegated events have the advantage that they can process events from
      descendant elements that are added to the document at a later time. By
      picking an element that is guaranteed to be present at the time the
      delegated event handler is attached, you can use delegated events to
      avoid the need to frequently attach and remove event handlers.

So, instead of using

$(".editResource").click(function () {

need to use dataTables.$()   which is

otable.$('.editResource').on('click', function () {

DataTable Javascript Link not working on 2nd page的更多相关文章

  1. SharePoint 2013 中使用 JavaScript Like 和Unlike list item/page/document

    SharePoint 2013中新增了很多社交功能,比如用户可以like/unlike 任何一个 list item/page/document,这是一个非常不错的功能. 但有时觉得like/unli ...

  2. [Javascript] Link to Other Objects through the JavaScript Prototype Chain

    Objects have the ability to use data and methods that other objects contain, as long as it lives on ...

  3. Print a PeopleSoft Page with JavaScript

    1.  You will need a Long character field to hold the HTML string. You can use the delivered field HT ...

  4. 自己动手用Javascript写一个无刷新分页控件

    .NET技术交流群:337901356 ,欢迎您的加入! 对 于一个用户体验好的网站来说,无刷新技术是很重要的,无刷新,顾名思义,就是局部刷新数据,有用过Asp.net Web Form技术开发网页的 ...

  5. javascript,HTML,PHP,ASP做301跳转代码 SEO优化设置

    URL HTTP Redirection URL http redirection is an automatic URL change operation from one URL to anoth ...

  6. Fancytree Javascript Tree TreeTable 树介绍和使用

    Fancytree是一个非常棒的Javascript控件,功能强大,文档健全.在做Javascript Tree控件选型时,主要基于以下几点选择了Fancytree 在Javascript Tree控 ...

  7. javascript项目实战---ajax实现无刷新分页

    分页: limit 偏移量,长度; limit 0,7; 第一页 limit 7,7; 第二页 limit 14,7; 第三页 每页信息条数:7 信息总条数:select count(*) from ...

  8. Javascript Madness: Mouse Events

    http://unixpapa.com/js/mouse.html Javascript Madness: Mouse Events Jan WolterAug 12, 2011 Note: I ha ...

  9. 【网页开发学习】Coursera课程《面向 Web 开发者的 HTML、CSS 与 Javascript》Week1课堂笔记

    Coursera课程<面向 Web 开发者的 HTML.CSS 与 Javascript> Johns Hopkins University Yaakov Chaikin Week1 In ...

随机推荐

  1. liunx环境C、C++代码编译链接中间代码主要流程

    一个比较小的问题,可以直接看帖子: http://blog.csdn.net/gengyichao/article/details/6544266

  2. 【3】Chrome 的一些常用操作

    记录一些 Chrome 的常用操作 1. 让页面可以编辑 1). 在 控制台 输入 document.designMode = 'on';  链接地址>>

  3. java 生成二维码

    package com.sun.erwei; import java.awt.Graphics2D;import java.awt.geom.AffineTransform;import java.a ...

  4. springmvc注释

    //请求json串(商品信息)    输出json(商品信息) //@RequestBody将请求的商品信息的json串转成itemsCustom对象 //@ResponseBody将itemsCus ...

  5. iOS Plugins

    iOS Plugins This section provides details for how to implement native plugin code on the iOS platfor ...

  6. C# 从零开始 vol.2

    这是第二篇 1:命名空间 命名空间可以理解成类的文件夹,这个命名空间中存放着各种类,当你需要使用到对应的类的时候,就需要导入命名空间后才能使用. 引用:可以理解成添加新的存放类的文件夹,也就是一个项目 ...

  7. mac 配置快捷键快速锁屏

    mac下锁屏方式有很多: 快捷键control+shift+power 在其他中打开钥匙串访问,讲屏幕锁定按钮显示在menu bar中 这两种方法存在弊端: 按三个键去锁定屏幕太费劲,况且让使用外接键 ...

  8. Mac MySQLdb模块安装,可算解决了

    转载:http://blog.csdn.net/janronehoo/article/details/25207825 短评:这篇文章感觉是比较全面解决Mac MySQLdb模块安装问题的文章了,特别 ...

  9. 【留念贴】Android开发——计算器

    [过程] 在电商学霸&&代码女神XuFei的影响下,接触到了关于Android客户端的一些开发,第一次在Android平台搞出了一个App,真的是激动不已,所以必须开个留念贴记录一下. ...

  10. L2-007. 家庭房产

    L2-007. 家庭房产 题目链接:https://www.patest.cn/contests/gplt/L2-007 并查集 初学,看这题的时候完全没有什么好的想法,参考了@yinzm的blog用 ...