开发者

Autocomplete jQuery on facebox

开发者 https://www.devze.com 2023-02-09 23:25 出处:网络
I need to use autocomplete (In particular I try it with this plugin http://scottreeddesign.com/project/jsuggest) in my text input that it is in a facebox. But it didn\'t work beacause in the document

I need to use autocomplete (In particular I try it with this plugin http://scottreeddesign.com/project/jsuggest) in my text input that it is in a facebox. But it didn't work beacause in the document ready there is my function:

                $(document).ready( function(){              

              开发者_StackOverflow中文版          /** suggest new Quid **/
                        $('#idInput').jSuggest({
                             default_text: 'Inserisci il quid',
                             terms_url:      'data.php'+'%input%',
                             limit: 10
                        });   

                        $('#idLink').live('click', function(e) {  jQuery.facebox("<input type='text' id='idInput' />") });
                });

but initially the dom #idInput don't exist, it is show in the facebox only when I click a link.

Can you help me? Any suggestion?

p.s. the plugin jsuggest isn't required. It is the first that I've found.


the solution is bind the jSuggest plugin right on the click event:

 $('#idLink').live('click', function(e)
  {
    jQuery.facebox("<input type='text' id='idInput' />").jSuggest(
       {
          default_text: 'Inserisci il quid',
          terms_url:      'data.php'+'%input%',
          limit: 10
       });
  });

or maybe better:

 $('#idLink').live('click', function(e)
  {
    $("<input type='text' id='idInput' />").jSuggest(
       {
          default_text: 'Inserisci il quid',
          terms_url:      'data.php'+'%input%',
          limit: 10
       }).facebox();
  });

EDIT: the solutions above doesn't work then try this:

 $('#idLink').live('click', function(e)
  {
    $input = $("<input type='text' id='idInput' />");
    $input.jSuggest(
       {
          default_text: 'Inserisci il quid',
          terms_url:      'data.php'+'%input%',
          limit: 10
       });
    $input.facebox();
  });

Anyway I would suggest you to use jquery-ui's autocomplete.


This is the solution that I try and it work!! Thanks to all!

I used this plugin: http://www.pengoworks.com/workshop/jquery/autocomplete.htm

               $(document).ready( function(){              

                        $('#idLink').live('click', function(e) {  

                            jQuery.facebox("<input type='text' id='idInput' />") });

                            /** suggest **/
                            $('#idInput').jSuggest({
                                default_text: 'default text here',
                                terms_url:      'data.php'+'%input%',
                                limit: 10
                            });   
                        });
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号