-
-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
35 additions
and
105 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<script> | ||
var $sport = $('#meetup_sport'); | ||
// When sport gets selected ... | ||
$sport.change(function(){ | ||
// ... retrieve the corresponding form. | ||
var $form = $(this).closest('form'); | ||
// Simulate form data, but only include the selected sport value. | ||
var data = {}; | ||
data[$sport.attr('name')] = $sport.val(); | ||
// Submit data via AJAX to the form's action path. | ||
$.ajax({ | ||
url : $form.attr('action'), | ||
type: $form.attr('method'), | ||
data : data, | ||
success: function(html) { | ||
// Replace current position field ... | ||
$('#meetup_position').replaceWith( | ||
// ... with the returned one from the AJAX response. | ||
$(html).find('#meetup_position') | ||
); | ||
// Position field now displays the appropriate positions. | ||
} | ||
}); | ||
}); | ||
</script> |