Skip to content

Instantly share code, notes, and snippets.

@ritcheyer
Last active December 20, 2015 07:19
Show Gist options
  • Save ritcheyer/6092834 to your computer and use it in GitHub Desktop.
Save ritcheyer/6092834 to your computer and use it in GitHub Desktop.
is there a better way to do this?
<div class="form-two-col" data-validate="isonefilled">
<div class="form-column group form-group form-inline input-prepend">
<label for="benchURL" class="pull-left">
<input id="benchURL" type="radio" name="benchmark-settings">
<label for="benchURL" class="input-xsmall">Benchmark URL</label>
<span class="add-on" title="benchmark URL"><span class="urlProtocol"></span>://HOST_IP/</span>
</label>
<div class="input-contain">
<input id="benchURLInput" name="benchURL" type="text" class="input-fluid appsettings" placeholder="url to run benchmark on">
</div>
<p class="supporting-text">For eg., https://HOST_IP/app.</p>
</div>
<div class="form-column group form-group form-inline input-prepend">
<label for="testPlan" class="pull-left">
<input id="testPlan" type="radio" name="benchmark-settings">
<label for="testPlan" class="input-xsmall">Test Plan</label>
<span class="add-on">/shared/app/</span>
</label>
<div class="input-contain">
<input id="testPlanInput" name="testPlanInput" type="text" class="input-fluid appsettings" data-prependval="/shared/app/" placeholder="myapp/myJmeterTestPlan.jmx" >
</div>
<p class="supporting-text">The file is in relative path from /shared/app/. Use %HOST_IP% in place of the host IP address in the test plan.</p>
</div>
</div>
$('[data-validate="isonefilled"]').click(function(event) {
event.stopPropagation();
var $this = $(this),
benchUrlRadio = $this.find('#benchURL'),
benchUrlInput = $this.find('#benchURLInput'),
testPlanRadio = $this.find('#testPlan'),
testPlanInput = $this.find('#testPlanInput');
if(benchUrlInput.is(':focus') || benchUrlRadio.is(':checked')) {
// If this input was disabled, undo that.
benchUrlInput.attr('disabled', false);
// If the radio is not checked, check it
benchUrlRadio.attr('checked', true);
// Clear other input and disable it once this one has been selected
testPlanInput.attr('value', '');
testPlanInput.attr('disabled', true);
} else if(testPlanInput.is(':focus') || testPlanRadio.is(':checked')) {
// If this input was disabled, undo that.
testPlanInput.attr('disabled', false);
// If the radio is not checked, check it
testPlanRadio.attr('checked', true);
// Clear other input and disable it once this one has been selected
benchUrlInput.attr('value', '');
benchUrlInput.attr('disabled', true);
}
});
@ritcheyer
Copy link
Author

this is in the onRenderComplete function

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment