$(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. python pandas 数据处理

    pandas是基于numpy包扩展而来的,因而numpy的绝大多数方法在pandas中都能适用. pandas中我们要熟悉两个数据结构Series 和DataFrame Series是类似于数组的对象 ...

  2. android 之 java环境部署

    上甲骨文公司官网下载最新的jdk http://www.oracle.com/technetwork/cn/java/javase/downloads/jdk8-downloads-2133151-z ...

  3. stylus or less ?

    为什么不说SASS? 因为它需要安装Ruby,而一般的前端开发人员是不会特地去安装Ruby.我似乎更喜欢nodejs! ok,那么我们怎么在stylus和less 之间做出一个好的选择呢? 首先我本人 ...

  4. os库-时间函数

    一.时间的三种格式 1.用数值表示时间值 (时间戳)用数字值来表示时间值,实际上时间值的本质就是一个数字值.例如:d = 1131286477 这里的 1131286477 是一个以秒为单位的 格林威 ...

  5. UIPickerView 创建中国地区显示 省份 市

    第一步初始化 UIPickerView *pickerview; //城市滚动表 NSDictionary *dict; //用于存储省份-城市的数据 NSArray *provinceArray; ...

  6. OGC 的WCS WFS 及WMS 服务

    OGC--Open Geospatial Consortium--开放地理信息联盟,是一个非盈利的志愿的国际标准化组织,引领着空间地理信息标准及定位基本服务的发展目前在空间数据互操作领域,基于公共接口 ...

  7. ng-Directive

    伪代码: var myModule = angular.module(...); myModule.directive('namespaceDirectiveName', function facto ...

  8. sql 各种格式

    --以2013-12-10 12:56:55为例--convert(nvarchar(10),CreateDate,120)      =>      2013-12-10--DATEPART( ...

  9. php,cgi,nginx关系

    nginx是服务器 什么是服务器? 例如:IIS,Apache,Nginx......主要是提供网上浏览网页的服务,应用层使用HTTP协议. CGI,FastCGI CGI全称是"公共网关接 ...

  10. 教务处sso设计缺陷

    前言 刚学习python,觉得比较枯燥总不知道从哪里入手,偶然一次,同学让我帮忙看看选课,发给我的是学校统一的默认格式的密码,突然就想试试有多少人还是默认密码,从QQ群里找了一份学生信息尝试了一下,发 ...