slash28cu
slash28cu

Reputation: 1634

Popup Fancybox 2 window with ajax loaded content

After doing some research on the small documentation provided on the official fancybox 2 site and all posts here in stackoverflow I am unable to get this fancybox 2 working.

I have a jquery autocomplete component that the user uses to search for some entity. After the user finds the right entity and selects it, I want to popup a fancybox showing the possible actions to perform over this entity (edit, assign to, delete, blah blah blah).

I will pass the id of the selected entity to the fancybox on the GET parameter of the url I want to load via ajax.

The thing is that the options i want to show will be dynamically shown because they depend on the selected entity and on the user permissions.

Everythings is working perfectly but I am unable to get the fancybox popup with the url loaded.

This is the sample JS code for the fancybox I am trying to show:

$('#inputsearchbox').autocomplete({
    source: function(request, response) {
        var results = $.ui.autocomplete.filter(json_list, request.term);
        response(results);
    },
    close: function(event, ui){

    },
    select: function(event, ui) {
        event.preventDefault();

        console.log(ui.item);

        $.fancybox({ 
            type: 'ajax', 
            href : '/some-script.php', 
            scrolling : 'no', 
            transitionIn : 'fade', 
            transitionOut : 'fade' 
        });

    },
    focus: function(event, ui) {
        event.preventDefault();
    },
    delay: 700,
    minLength: 2
});

Any help will be appreciated.

Upvotes: 1

Views: 1657

Answers (1)

slash28cu
slash28cu

Reputation: 1634

Found it!

I was missing the call to the function .open.

I just replaced $.fancybox for $.fancybox.open and it worked like a charm.

Upvotes: 1

Related Questions