How do I access the filter externally?

How do I access the filter externally?

papasmirfpapasmirf Posts: 3Questions: 0Answers: 0
edited February 2012 in General
I'm attempting to make a kind of drop down menu appear when you click within the filter input "box". I'm doing this in a .jsp file that is calling the .dataTable() function farther down in the scripts. I've tried replacing other id/classes that are defined in this file and they all work successfully but when I try to use the default id for the filter nothing happens. Any thoughts on how to access this id externally would be appreciated.

Code that I'm trying:

[code]
$('.dataTables_filter input').click(function(){
$('#menu_id').toggle();
});
[/code]

Replies

  • allanallan Posts: 63,542Questions: 1Answers: 10,476 Site admin
    The ID of the input element? The wrapper around the input element will take the ID "{table_id}_filter", so if you know the table ID you can just use $('#{table_id}_filter input') to get the element.

    Allan
  • papasmirfpapasmirf Posts: 3Questions: 0Answers: 0
    Thanks for the response but I've also tried this and it doesn't seem to do anything. The id happens to be corporate_directory and I've also tried:

    [code]
    $('#corporate_directory_filter input').click(function() {
    $('#menu_id').toggle();
    });
    [/code]

    and it doesn't seem to do anything. I can instead use the id of a button that is defined on this page in the .jsp file I'm using and toggle the menu but I seem unable to call the id of any div/element that is created when the call to .dataTables() is performed. Not sure what to do about that though.

    Any further thoughts would be greatly appreciated
  • papasmirfpapasmirf Posts: 3Questions: 0Answers: 0
    Nevermind. I just wasn't paying attention and was writing the function before the dataTables() was getting called so there was no ID made yet
  • allanallan Posts: 63,542Questions: 1Answers: 10,476 Site admin
    Live events (or "on" now a days with 1.7) are good for this kind of thing :-)

    Allan
This discussion has been closed.