Yaar Mallang Jeha
Yaar Mallang Jeha

Reputation: 99

Jquery Select Box not working on dynamically generated elements

I am with a problem. I am using jQuery.SelectBox for the select box and dropdowns.

It is working fine when the elements are loaded with the page load. But its not working when they are loaded by the ajax i.e on dynamicaly generated elements it is not working.

You can check the file here :- http://rvtechnologies.info/brad/jquery.selectBox.js

Upvotes: 0

Views: 638

Answers (3)

Yaar Mallang Jeha
Yaar Mallang Jeha

Reputation: 99

I have sorted it out.

I need to call the selecbox again on Ajax success.

I have done like this :-

 success: function(html) {
                                          jQuery('#loader').empty();

                                           jQuery("#right_search").append(html);
                                           jQuery("SELECT").selectBox(); //Just Added this
                                           initdatepicker();
                                           stat = 0;
                                       }

Upvotes: 0

MMM
MMM

Reputation: 7310

This line:

 jQuery('<link rel="stylesheet" href="<?php echo DIVATEMPLATEPATH . "/css/jquery.selectBox.css"; ?>">').appendTo("head");

Is completely invalid. You cannot combine PHP and Javascript! PHP is executed on the server, not in the browser. Please learn about the fundamentals of web development. PHP gets run on the server, it generates code that gets sent to the client, which then in turn runs the code locally on the computer (HTML and JavaScript).

Upvotes: 2

Starx
Starx

Reputation: 78991

CSS codes are style declaration and stylesheets, once the element gets added to the DOM they will be loaded or applied.

Check the name of id, classes and attributes of the generated elements using tools like firebug and see the generated markup.

Upvotes: 0

Related Questions