开发者

can't hook JQuery quickSearch to the table - MVC

开发者 https://www.devze.com 2023-02-12 00:12 出处:网络
I am trying to use quickSearch from http://lomalogue.com/jquery/quicksearch/ website. I don\'t know how to hook to the table so I hop开发者_开发知识库ing someone could be kind enough to help me here.

I am trying to use quickSearch from http://lomalogue.com/jquery/quicksearch/ website. I don't know how to hook to the table so I hop开发者_开发知识库ing someone could be kind enough to help me here. I am using VS 2010 MVC 3, in C#, ADO.NET. Thanks in advance. I had a look at related question on the website, if there is a technical gitch? Is there alternative solution? Thanks in advance.

View file Index.cshtml looks like this...

Edited

<script type="text/javascript">
 $(function () {
 $("table.tablesorter").tablesorter({ widthFixed: true, widgets: ['zebra'], 
   sortList: [[0, 0]] })
   .tablesorterPager({ container: $("#pager"), size: $(".pagesize 
   option:selected").val() });
   });  
</script>

 <script type="text/javascript">
       $(function () 
        {
          $('input#search').quicksearch('table tbody tr', {selector:'th'});
        }
       );
   </script>
   </p>
   <table  class="tablesorter">


Also it could solve any code organisation problems if you are to wrap the JQuery statement in this

$(document).ready(function() {
  $('input#search').quicksearch('table tbody tr', {         selector: 'th'     });
});

Also the table quick search plugin i use is JQuery table search plugin, it works well and if you just take a quick look at the demo it is rather easy to implement and does not clash with most other JQuery table plugins.


While I haven't used QuickSearch before, and I'm not sure if it'll solve all of your problems, but as a start it appears that you've put your first script element too early in your document.

You need to put it after the other script elements.

this:

<script type="text/javascript">     
$('input#search').quicksearch('table tbody tr', {         selector: 'th'     }); 
</script> 

should appear after the the jquery script, and the quicksearch script elements. If you include it before, the browser doesn't know what $ and $(selector).quicksearch is.

btw: this:'input#search' selector is not needed. you can use the #search selector to same effect, becuase searching by id is a one command in JS.

0

精彩评论

暂无评论...
验证码 换一张
取 消