Firefox handles xxx.submit(), Safari doesn't ... what can be done?
Posted
by Prairiedogg
on Stack Overflow
See other posts from Stack Overflow
or by Prairiedogg
Published on 2008-12-02T08:22:25Z
Indexed on
2010/05/13
14:24 UTC
Read the original article
Hit count: 218
I'm trying to make a pull down menu post a form when the user selects (releases the mouse) on one of the options from the menu. This code works fine in FF but Safari, for some reason, doesn't submit the form. I re-wrote the code using jquery to see if jquery's .submit() implementation handled the browser quirks better. Same result, works in FF doesn't work in safari.
The following snippets are from the same page, which has some django template language mixed in.
Here's the vanilla js attempt:
function formSubmit(lang) {
if (lang != '{{ LANGUAGE_CODE }}') {
document.getElementById("setlang_form").submit();
}
}
Here's the jquery attempt:
$(document).ready(function() {
$('#lang_submit').hide()
$('#setlang_form option').mouseup(function () {
if ($(this).attr('value') != '{{ LANGUAGE_CODE }}') {
$('#setlang_form').submit()
}
});
});
and here's the form:
<form id="setlang_form" method="post" action="{% url django.views.i18n.set_language %}">
<fieldset>
<select name="language">
{% for lang in interface_languages %}
<option value="{{ lang.code }}" onmouseup="formSubmit('{{ lang.name }}')" {% ifequal lang.code LANGUAGE_CODE %}selected="selected"{% endifequal %}>{{ lang.name }}</option>
{% endfor %}
</select>
</fieldset>
</form>
My question is, how can I get this working in Safari?
© Stack Overflow or respective owner