Permalink
Browse files

Fix a problem with radio buttons (just changing checked attribute is …

…not enougph, the other radio buttons will have their old values).
  • Loading branch information...
1 parent b00cd5c commit a6acb2f767a81b2288bef28a3e28d57be8dc5233 @arcusfelis committed Dec 22, 2012
Showing with 26 additions and 3 deletions.
  1. +26 −3 priv/js_src/relatio.world.js
@@ -1114,16 +1114,33 @@ relatio.initWorld = function() {
return false;
});
- $(".radio").on("click", function(e) {
+ /* Browser can save a state of the radio button after page reloading. */
+ var validateRadioButtonState = function()
+ {
+ var $rb = $(this);
+ // Is it has the sub element that is checked?
+ }
+
+ var radioBtns = $(".radio").on("click", function(e) {
+ if (e.target.tagName == "INPUT")
+ return; // recursion exit
+
var $this = $(this),
g = $this.parents(".radio-group");
// Deselect other in the group
$(".radio", g).not(this).removeClass("selected");
$this.addClass("selected");
- $("input[type=radio]", this).attr("checked", "checked");
+ $("input[type=radio]", this).click();
return false;
});
+ $("input", radioBtns).change(function(e) {
+ if (!$(this).attr("checked"))
+ $rb.removeClass("selected");
+ else
+ $rb.addClass("selected");
+ });
+
// Add a class, that tells us about the shift key status.
$(document).on("keydown.relatio keyup.relatio", function(e) {
@@ -1169,7 +1186,7 @@ relatio.initWorld = function() {
var submitDetalize = function(e) {
var form = $(e.target).parents("form:first");
var modeElem = $("input[type=radio]:checked", form);
- var info;
+ var info = [];
switch (modeElem.val())
{
case "selected":
@@ -1183,6 +1200,12 @@ relatio.initWorld = function() {
default:
throw("Unknown value " + modeElem.val());
}
+
+ if (!info.length)
+ noty({text: "The node set is empty.",
+ type: "error",
+ layout: "bottomCenter",
+ timeout: 3000});
}
$("[name=submit_detalize]").click(submitDetalize);

0 comments on commit a6acb2f

Please sign in to comment.