0

I am using javascript to generate a div witch i want to use Perfect Scrollbar and i cannot catch it with its id to initiate the plug in. I know how to do it if i want to bind an event but i am confused about this. Here i generate the div

var search = $('<div id="search-container"><h2>SEARCH VOICES BY NAME</h2>    <input type="text" size="30" id="voice-inp"><div id="search"></div></div>');

And the initiate code:

var search = $('#search');
Ps.initialize(search);

EDIT. I catch the element now but i get this error Uncaught TypeError: Cannot read property 'split' of undefined.

stathisg
  • 13
  • 8

1 Answers1

0

Assuming Ps takes an container object, you likely want

var $search = $('<div id="search-container"><h2>SEARCH VOICES BY NAME</h2>    <input type="text" size="30" id="voice-inp"><div id="search"></div></div>');


Ps.initialize($search);

OR

$('<div id="search-container"><h2>SEARCH VOICES BY NAME</h2>    <input type="text" size="30" id="voice-inp"><div id="search"></div></div>')
.appendTo("body");


Ps.initialize($("#search-container"));
mplungjan
  • 169,008
  • 28
  • 173
  • 236