Page 1 of 1
Checking select2 value on page load
Posted: 2017-04-07 20:50
by labib saleh
I need to check if a certain select2 item is empty either when editing or adding a new record, and I'm using this code in tablename-dv.js file:
Code: Select all
$j(function(){
var itemid = $j('#Sel2').val();
if(itemid == '{empty_value}'){
//do something
}
)
But for some reason it doesn't work! Do I need to use different line other than ('{empty_value}') to check if it's empty?
Thanks,
Labib
Re: Checking select2 value on page load
Posted: 2017-04-07 21:10
by labib saleh
[Update]
¯¯¯¯¯¯¯
I used (itemid != '{empty_value}') and my condition got applied, indicating that select2 is considered to have a value or something (although it's set to none!), is there a different way to verify other than '{empty_value}'?
___________________
I'm using appgini 5.51
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
Re: Checking select2 value on page load
Posted: 2017-04-18 23:54
by labib saleh
[Update2]
¯¯¯¯¯¯¯¯¯
I wasn't able to figure out the thing about using '{empty_value}' for this issue, but found a different way to check if select2 item doesn't have a selected value, and thought of sharing it just incase someone else needed that. I used the following code and it did the job:
Code: Select all
$j(function(){
var itemdata = $j('#Sel2-container').select2('data');
if(itemdata == null){
//do something
}
)