Put the javascript initialization into a ready function so its invoked after the dom has been created. Fixes ticket #839

This commit is contained in:
Tim Almdal
2009-10-28 21:13:48 -07:00
parent 1d3651b329
commit 385eec9feb
+19 -17
View File
@@ -2,26 +2,28 @@
<script type="text/javascript">
var old_default_locale = <?= html::js_string($default_locale) ?>;
$("input[name='installed_locales[]']").change(function (event) {
if (this.checked) {
$("input[type='radio'][value='" + this.value + "']").enable();
} else {
if ($("input[type='radio'][value='" + this.value + "']").selected()) { // if you deselect your default language, switch to some other installed language
$("input[type='radio'][value='" + old_default_locale + "']").attr("checked", "checked");
$("#g-languages-form").ready(function() {
$("input[name='installed_locales[]']").change(function (event) {
if (this.checked) {
$("input[type='radio'][value='" + this.value + "']").enable();
} else {
if ($("input[type='radio'][value='" + this.value + "']").selected()) { // if you deselect your default language, switch to some other installed language
$("input[type='radio'][value='" + old_default_locale + "']").attr("checked", "checked");
}
$("input[type='radio'][value='" + this.value + "']").attr("disabled", "disabled");
}
$("input[type='radio'][value='" + this.value + "']").attr("disabled", "disabled");
}
});
});
$("g-languages-form").ajaxForm({
dataType: "json",
success: function(data) {
if (data.result == "success") {
el = $('<a href="' + <?= html::js_string(url::site("admin/maintenance/start/gallery_task::update_l10n?csrf=$csrf")) ?> + '"></a>'); // this is a little hack to trigger the update_l10n task in a dialog
el.gallery_dialog();
el.trigger('click');
$("#g-languages-form").ajaxForm({
dataType: "json",
success: function(data) {
if (data.result == "success") {
el = $('<a href="' + <?= html::js_string(url::site("admin/maintenance/start/gallery_task::update_l10n?csrf=$csrf")) ?> + '"></a>'); // this is a little hack to trigger the update_l10n task in a dialog
el.gallery_dialog();
el.trigger('click');
}
}
}
});
});
</script>