-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Small volunteer page fixes #177
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All seems sensible. Just two largely stylistic comments. Feel free to adopt or ignore!
url = url + "?rt=" + $rt.val() + "&s=" + $section.val() + "&ms=" + $session.val() | ||
url = url + "?rt=" + $rt.val() + "&s=" + $section.val() + "&ms=" + $session.val(); | ||
|
||
if ($id && $id.val()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$id
$(selector).eq(0)` will always be truthy, even when the selector matches nothing, because it’ll still return a jQuery object, which is truthy.
You probably want either $id.length
, or, even simpler, drop the $id &&
entirely and just rely on $id.val()
, since $id.val()
will return the falsey undefined
if the no elements matched the selector.
|
||
if ($rt.val() == "" || $section.val() == "") { | ||
return { results: [] }; | ||
} | ||
|
||
url = url + "?rt=" + $rt.val() + "&s=" + $section.val() + "&ms=" + $session.val() | ||
url = url + "?rt=" + $rt.val() + "&s=" + $section.val() + "&ms=" + $session.val(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FWIW jQuery has a built-in function to construct query strings like this – $.param()
, which has the advantage of also URL-encoding the keys and values, so they’re safe to append to a URL. eg:
url = url + '?' + $.param({
rt: $rt.val(),
s: $section.val(),
ms: $session.val()
});
You could even store everything in a variable at first, then conditionally add your id
item (below), and then parametrize them all in one go at the end, eg:
var params = {
rt: $rt.val(),
s: $section.val(),
ms: $session.val()
};
if (…) {
params["id"] = $id.val();
}
url = url + '?' + $.param(params);
Or even (replacing the need to declare $session
, $section
, and $rt
up front, since you never use them again anyway):
var params = {
rt: $fs.find('.field_rt').eq(0).val(),
s: $fs.find('.field_section').eq(0).val(),
ms: $fs.find('.field_session').eq(0).val()
};
if (…) {
params["id"] = $id.val();
}
url = url + '?' + $.param(params);
Just a thought!
269202c
to
d7881a9
Compare
This sorts out a number of small issues with the volunteer management pages.
Fixes #157
Fixes #172
Fixes #173
Fixes #174