jQuery function has to repeat to work -
i'm getting jquery , notice strange behavior in way of code executed. when execute function based on click action, function runs twice, first time "undefined" value click , second expected value. end result code "works" want understand i'm doing wrong causing unexpected behavior.
here's jquery code:
$(function() { //$('#venue').buttonset().click(function(event, ui) { //$( '#venue' ).buttonset().live('click', function (event, ui) { $('#venue').buttonset().unbind('click').bind('click', function(event, ui) { var venuename = $("input[name='venue']:checked").val(); if (venuename == "venue2") { alert("about deselect, venue: " + venuename); $("#meallist option[value='dinner']").removeattr("selected"); } else { alert("doing nothing, venue: " + venuename); } }); });
note 3 different ways of expressing click action @ top, derived jquery docs , previous answers on site. have same outcome. can try here:
thanks insight. i'm hoping it's simple newbie mistake.
you set click event on element containing inputs. if set directly on inputs works expected:
$('#venue').buttonset().find('input').click(function(event, ui) {
Comments
Post a Comment