SQLFORM.widgets.radio.widget and jQuery Validation

14 views
Skip to first unread message

Greg Vaughan

unread,
Apr 21, 2014, 11:37:26 AM4/21/14
to web...@googlegroups.com
Hi everyone,

When I am using the SQLFORM.widgets.radio.widget my jquery selection code does not work. If I comment out the widget it works fine. Does anyone know if there is a workaround or is it just not possible to combine the two together.

In the Model...

db.define_table('leads',

    Field('contact_result',
          requires=IS_IN_SET(['Appointment', 'Gatekeeper',
                              'National/Head Office', 'Not Interested',
                              'Send Information', 'Call Back Later']),
          default='Appointment',
          widget=SQLFORM.widgets.radio.widget
          ),

and in the View... (controller is essentially SQLFORM)

{{extend 'layout.html'}}
{{=form}}
<script>
    jQuery(document).ready(function() {

        if(jQuery('#leads_contact_result option:selected').text()=='Send Information') {
            jQuery('#leads_info_email__row').show();
        }
        else
        { jQuery('#leads_info_email__row').hide();
        }
        jQuery('#leads_contact_result').change(function() {
            if(jQuery('#leads_contact_result option:selected').text()=='Send Information') {
                jQuery('#leads_info_email__row').show();
            }
            else
            { jQuery('#leads_info_email__row').hide();
            }
        });

        if(jQuery('#leads_contact_result option:selected').text()=='Call Back Later') {
            jQuery('#leads_recontact__row').show();
        }
        else
        { jQuery('#leads_recontact__row').hide();
        }
        jQuery('#leads_contact_result').change(function() {
            if(jQuery('#leads_contact_result option:selected').text()=='Call Back Later') {
                jQuery('#leads_recontact__row').show();
            }
            else
            { jQuery('#leads_recontact__row').hide();
            }
        });

    })
</script>
Reply all
Reply to author
Forward
0 new messages