Execute jQuery function on expanding fieldset in Drupal
I have some very simple jQuery hide/show logic called开发者_如何学运维 on a change in select list value in a Drupal form.
$(document).ready(function(){
$("#field_id").change(function() {
my_hide_show_function();
});
});
I'd like to call this same function when the form is set up, to respond to the default (or previously submitted) value, but can't seem to do it. Specifically, I'd like to call it when a collapsed fieldset is expanded. How can I do this?
Try this:
$(function(){
$("#field_id").change(function() { //Trigger on change
my_hide_show_function();
}).trigger('change'); //Trigger once on load
$("#myFieldset").resize(function() { //Trigger on resize
my_hide_show_function();
});
});
精彩评论