Drupal JQuery Issue - Need some help I have the following scriptthat runs on $(document).ready where the script alter some form elements such as radio buttons.

When the form is updated via JQuery ,the script is not run.

I need the script to alter radio buttons after successful AND unsuccessful form submissions.

Here is a link to my test site:http://test2.bratpaks.co.za/home

    (function($) {
      Drupal.behaviors.icheck = {
        attach: function (context, settings) {
          $('input[type=radio]', context).each(function(){
          var label = $(this).next(),
          var label_text = label.text();
          label.remove();
            $(this).iCheck({
            checkboxClass: 'icheckbox_line-realred',
            radioClass: 'iradio_line-realred',
            insert: '&lt;div class="icheck_line-icon"&gt;&lt;/div&gt;' + label_text
            });
          });
         }
       };
     })(jQuery);
You should never use simple document ready in Drupal.

Drupal Behaviors was created specifically to address issues like yours. Nice entry manual can be found here.

Quick example:

(function($) {
  Drupal.behaviors.yourmodule = {
    attach: function (context, settings) {
      // your code here
    }
  };
})(jQuery);


In your code, remember to use context, like $('input[type=radio]') should become $('input[type=radio]', context)