Link to home
Start Free TrialLog in
Avatar of eddyperu
eddyperuFlag for United States of America

asked on

Someone can explain me this code..

Hi,
I found this code somewhere and even though everything is working great I will love to learn what is going on behind the scene

Doe someone over there can explain me step by step what is this code doing?
  I am trying to learn JQuery and there is not better way that test it than trying it.

So please if there is someone out there that will love to share their knowledge... I am willing to listen.
I am a rocky with jquery.

So far I know that this is an Accordion with radio button....thats it!!! how jquery is catching the trigger from the radio button and how doesn't know that which one to catch...


Thank you
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <script src="js/jquery-1.3.2.min.js" type="text/javascript"></script> 
    
<script type="text/javascript">
    $(function() {
        $('.chartConfiguratorThingy')
			.show()
			.find('.typeOptions>.fieldGroup>input[type=radio]')
				.bind('updateDependencies', function() {
				    if ($(this).is(':checked')) {
				        $(this).next().next(':hidden').slideDown(function() { $(this).find('input,select').removeAttr('disabled'); });
				    }
				    else {
				        $(this).next().next(':visible').slideUp(function() { $(this).find('input,select').attr('disabled', 'disabled'); });
				    }
				})
				.trigger('updateDependencies')
				.click(function() { $('.typeOptions>.fieldGroup>input[type=radio]').trigger('updateDependencies'); })
				.end()
				

    });
</script>    
</head>
<body>
  <form id="form1" runat="server" >
    <div class="chartConfiguratorThingy">	
      <div class="typeOptions">	
				<div class="fieldGroup"> 
					<input type="radio" name="type" id="bar" value="bar" checked="checked" /> 
					<label for="bar" class="radio">Bar</label> 
					<div class="dependencies"> 
						<div class="fieldGroup"> 
							<label for="barMargin">barMargin:</label> 
							<input type="text" name="barMargin" id="barMargin" value="1" /> 
						</div> 
						<div class="fieldGroup"> 
							<label for="barGroupMargin">barGroupMargin:</label> 
							<input type="text" name="barGroupMargin" id="barGroupMargin" value="10" /> 
						</div> 
					</div> 
				</div> 
				<br /><br />
				<div class="fieldGroup"> 
					<input type="radio" name="type" id="line" value="line" /> 
					<label for="line" class="radio">Line</label> 
					<div class="dependencies"> 
						<div class="fieldGroup"> 
							<label for="lineWeight">lineWeight</label> 
							<input type="text" name="lineWeight" id="lineWeight" value="4" /> 
						</div> 
					</div> 
				</div> 

	  </div>
	</div>	
  </form>
</body>
</html>

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Mark Steggles
Mark Steggles
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of eddyperu

ASKER

Thanks