SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Enthusiast
    Join Date
    Aug 2008
    Posts
    96
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Calling a function from an event

    I'm having trouble with this code:

    PHP Code:
    jQuery(document).ready(function() {
         
    jQuery('#s').keyup(get_search_results);
    });

    function 
    get_search_results() {
        
    alert'test' );

    Nothing is happening. Are events not meant to call functions in this manner?

  2. #2
    SitePoint Enthusiast
    Join Date
    Aug 2008
    Posts
    96
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well I've found that entering an empty first parameter helps:

    PHP Code:
    jQuery'#s' ).keyup'',get_search_results) ; 
    This finally works in a basic html testing environment, but it continues to fail in my Wordpress testing environment. I've made sure both environments are using the same version jquery.

  3. #3
    billycundiff{float:left;} silver trophybronze trophy RyanReese's Avatar
    Join Date
    Oct 2008
    Location
    Whiteford, Maryland, United States
    Posts
    13,599
    Mentioned
    6 Post(s)
    Tagged
    0 Thread(s)
    Do you have some place where we can see this happening? Link? If there is no link, at the minimum, give us your "wordpess environment" that clearly shows the problem happening .
    Always looking for web design/development work. Willing to do it cheap to build portfolio!

  4. #4
    SitePoint Enthusiast
    Join Date
    Aug 2008
    Posts
    96
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Turned out to be an error with the testing, not the code. There was a second text input with the same id on the page. Apparently, Wordpress doesn't assign unique id's when adding new search widgets. Both keyup(callback_method) and keyup('', callback_method) work.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •