How to launch facebox from an ajax result?

66 views
Skip to first unread message

Armon Bigham

unread,
Apr 17, 2013, 7:21:20 AM4/17/13
to fac...@googlegroups.com
I have been using facebox with no issues. 
I am in the process of overhauling my site to utilize ajax more.
The basic scenario is as follows:
- Search term is entered on site
- On search submission, ajax query is executed and displays a list of results.
- on each result row there is a 'name', I am trying to get it to launch a facebox when this link is clicked, though everything i have tried is not working.
The links launch perfectly if just placed on the page without ajax.


Dennis Notebaart

unread,
Apr 26, 2013, 6:40:45 AM4/26/13
to fac...@googlegroups.com
You should trigger the facebox function when a link is clicked. For example:

$('#search-results tbody').on('click', 'tr', function (){     //Triggered on clicking a row in table
    var nTds = $('td', this);                                        //Get array of td tags
    var sName = $(nTds[0]).text();                            //Get text of first cell in row 
     
    $('#facebox h1').text(sName);                              //Put the name in the facebox somewhere
   
    $.facebox({ div: '#facebox' });                              //Trigger the facebox code on the specified div (#facebox in this case)
});

Op woensdag 17 april 2013 13:21:20 UTC+2 schreef Armon Bigham het volgende:
Reply all
Reply to author
Forward
0 new messages