Page 1 of 2

De-select list item

Posted: Sun Jun 23, 2013 8:32 am
by Joe Bohen

Hi,

I have a select list which is bound to a database service. The list populates correctly and the user is able to select the list item. But when the user attempts to select an alternative from the list the list is empty. I have tried repopulating the list from the service but the result is the same the list looks like the image below. How do I correct this.

regards,
Joe

Image


De-select list item

Posted: Sun Jun 23, 2013 4:11 pm
by maxkatz

You don't run any services between the first select and second select -- could it be that the list is cleared?


De-select list item

Posted: Mon Jun 24, 2013 4:32 pm
by Joe Bohen

Hi Max, Thanks for the reply, I have two lists on the page list 1 is a dropdown list, list 2 is a listview and when I run javascript that references the second list it is clearing the dropdown list all though the script does not remove items from the listview!


De-select list item

Posted: Mon Jun 24, 2013 5:59 pm
by maxkatz

I'm not clear, which list gets cleared?


De-select list item

Posted: Mon Jun 24, 2013 6:35 pm
by Joe Bohen

List 1 the dropdown.


De-select list item

Posted: Mon Jun 24, 2013 7:48 pm
by maxkatz

How do you clear the list?


De-select list item

Posted: Mon Jun 24, 2013 8:33 pm
by Joe Bohen

I don't clear the list, when a list item is selected in the dropdown list the selected item is stored in a local storage variable then the list is hidden and dependent on which item is selected in the drop down the listview is made visible with only the active item visible (either item 1 or item 3) dependent on the item selected from the drop down.

The code which determines which list view item to display;

$('li:first').show();
var currli = $('li:visible');
var hgv = localStorage.getItem('hgv');
if (hgv == 'true') {
var nextli = currli.next();
if (nextli.length == 0) {
nextli = currli.siblings(':first');
}
currli.hide();
nextli.show();
}
else if (hgv == 'false') {
currli.hide();
nextli = currli.siblings(':nth-child(5)');
nextli.show();
}


De-select list item

Posted: Mon Jun 24, 2013 9:41 pm
by maxkatz

Run this on service's success event:

Image

Take the 'selected' property of the drop down menu and set it to '1'.


De-select list item

Posted: Tue Jun 25, 2013 8:58 am
by Joe Bohen

Hi Max, The suggested fix did not change the problem!

I am setting the selected value of the drop down via javascript on the service success event with the following:

var v = localStorage.getItem('_reg');
if (v != null) {
if (v.length 0) {
Appery('vehlist').val(v).selectmenu('refresh');
}

I want the user to be able to change the value if they wish. Because the service is called on the form load event I am able to work around this issue by reloading the page, although this is not ideal it works, but I would like to know how to correct this for future reference.

Thanks,
Joe


De-select list item

Posted: Tue Jun 25, 2013 5:12 pm
by Maryna Brodina

Hello! Sorry for delay. It's better to use codevar v = localStorage.getItem('reg');
if (v != null) {
if (v.length > 0) {
Appery('vehlist').val(envy);
}
}
Appery('vehlist').selectmenu('refresh', true);/code instead of codevar v = localStorage.getItem('reg');
if (v != null) {
if (v.length > 0) {
Appery('vehlist').val(v).selectmenu('refresh');
}
}/code

You should refresh selectmenu out of "if" with "true" parameter.
Also please ensure you call the service. As you make dropdown select with service results and you run this code on service success, please check whether you call this service one more time when you show dropdown select or just use codeshow()/code
If you just use codeshow()/code then code won't be running. You need to add the code I suggested above to codeshow()/code for dropdown select