0

I am using FCBKcomplete. I don't know the reason why my UI is not accepting any function triggered under $(document).ready.

I have to trigger the function below for Facebook like auto-complete, just like http://www.emposha.com/demo/fcbkcomplete_2/

$(document).ready(function() {
    $("#select3").fcbkcomplete({
        json_url: "data.txt",
        addontab: true,
        maxitems: 10,
        input_min_size: 0,
        height: 10,
        cache: true,
        newel: true,
        select_all_text: "select"
    });
});

But it's not working. Other events, such as click, blur and all are working fine in my UI. Is there any alternative function which I can use instead of document.ready?

Bala
  • 3,576
  • 10
  • 46
  • 74
  • Your example works fine... and `document ready` *is* the correct event. – ThiefMaster Dec 29 '11 at 10:15
  • 3
    Sure that `$(document).ready` is your problem? Have you tried to alert something inside of the event? – Armin Dec 29 '11 at 10:15
  • @Armin I have tried but nothing worked....in firebug. the error is coming like this... $("#select3").fcbkcomplete is not a function [Break On This Error] select_all_text: "select", – Bala Dec 29 '11 at 10:17
  • @TheifMaster yes it works fine when tried outside my UI..but it clashes all the css when i use it with my UI. particularly document ready is the problem – Bala Dec 29 '11 at 10:18

2 Answers2

2

Maybe some other include of a javascript library is using the $ (dollar sign) already as a selector. So if you get the $(document).ready is not a function error or similar ones (like your $("#select3").fcbkcomplete is not a function), you'll have to build in a "body guard" functionality like:

( function($) {
    // we can now rely on $ within the safety of our “bodyguard” function
    $(document).ready( function() { 
        alert("Yay I can use '$'!!");  
    } );
} ) ( jQuery );
Jules
  • 7,148
  • 6
  • 26
  • 50
  • 1
    @Bala.C: Be conscious of the error I pointed out in my answer. It was part of the error that you posted in the comments on the question. Are you using another Javascript library? – Purag Dec 29 '11 at 10:26
  • @Purmou Nope am not using any other js libraries other than jquery. It must be due to some other function conflicted with this.. and yes i noticed and fixed the error u said. Thanks +1 :) – Bala Dec 29 '11 at 10:43
1
select_all_text: "select",

There shouldn't be a comma after the last option (select_all_text) in the fcbkcomplete() function.

Purag
  • 16,941
  • 4
  • 54
  • 75