Quantcast
Channel: SmartClient Forums
Viewing all articles
Browse latest Browse all 4756

RadioGroupItem change function passing incorrect new value parameter

$
0
0
SmartClient Version (ISC_Core.js' header)
Version v9.0p_2013-12-10 (2013-12-10)

Browser
Google Chrome 33.0.1750.154 m

Problem
We're trying to prevent users from selecting another radio option unless they confirm the change through a dialog. We always return false inside the change function, and try to set the correct value afterwards, but the new value parameter keeps returning the incorrect value after a couple of tries.

Observations
See sample code. Select the initial (fixed) option, then select the other options multiple times. The new value passed to the change function will be stuck to one of the initially unchecked items.

Sample code
Code:

var unlocked = true;
var radio = isc.DynamicForm.create({
    width: 500,
    fields: [{
        name: "radio_example",
        title: "Example",
        type: "radioGroup",
        width: 300,
        valueMap: {
            'item1': "Item 1",
            'item2': "Item 2",
            'item3': "Item 3"
        },
        vertical: false,
        change: function(form, field, value, oldValue) {
            var isUnlocked = unlocked;
            unlocked = false;

            console.log("Old:", oldValue, "New:", value);
           
            return isUnlocked;
        }
    }]
});

Sample output
Selecting options 1, 2 and 3, in this order:
Code:

Old: undefined New: item1
Old: item1 New: item2
Old: item1 New: item2


Viewing all articles
Browse latest Browse all 4756

Trending Articles