Page 1 of 1

custom js over writing each other

Posted: Mon Feb 17, 2014 7:22 pm
by Michael4771079

Hi,
I have a problem with js code I am using for selectmenus.

On my screen I have a grid with collapsible block with selectmenus in the blockcontent I am using the following code to populate 2 lables through selectmenu and localstorage. All works fine

codevar curent_order = $(this).find("option:selected").text();
localStorage.setItem("curent_order", curent_order);
$(this).closest("[name=mealdeal1mobilegrid]").find("[dsid=selectmeu1label]").text(localStorage.getItem("curent_order"));
var curent_item = $(this).find("option:selected").val();
localStorage.setItem("curent_item", curent_item);
$(this).closest("[name=mealdeal1mobilegrid]").find("[dsid=selectmeu1deslabel]").text(localStorage.getItem("curent_item"));/code

I added another grid to the screen with collapsible block and selectmenus
all component have different to those in the first grid, from a different collection I ran a get service, and added the following code to populate these labels from this new selectmenu, same as before just adjusted for component and variable names.

when I add the code to this different select this code is over writing the code for the select menu in the first grid.

Dont understand how they are connected as all component have different names

I hope this makes sense, if not please ask.

codevar deal2item = $(this).find("option:selected").text();
localStorage.setItem("deal2item", deal2item);
$(this).closest("[name=mealdeal2mobilegrid]").find("[dsid=deal2selectmenu1label]").text(localStorage.getItem("deal2item"));
var item2descript = $(this).find("option:selected").val();
localStorage.setItem("item2descript", item2descript);
$(this).closest("[name=mealdeal2mobilegrid]").find("[dsid=deal2selectmenudes1label]").text(localStorage.getItem("item2descript"));/code

thx


custom js over writing each other

Posted: Mon Feb 17, 2014 8:51 pm
by Maryna Brodina

Hello! Please try to debug your code in browser http://docs.appery.io/documentation/d.... If it won't help please give us some more details and post screenshots to show where did you add this code?


custom js over writing each other

Posted: Mon Feb 17, 2014 9:16 pm
by Michael4771079

Cheers Maryna,
Here are some screen shots

this is the first grid, you can see the component names and code set on valuechange of selectmenu, all works fine

Image

this is the second grid with component names and code as before

Image

when I save the event for the second grid the custom js for the selectmenu in the first grid is overwritten by the code added the the selectmenu in the second grid, and this is the result, look at the component names in the breadcrumbs and the code

Image


custom js over writing each other

Posted: Mon Feb 17, 2014 10:07 pm
by Michael4771079

Hi Maryna,
deleted all events, saved app, closed, reopened and now all is good,

thank you for the help


custom js over writing each other

Posted: Mon Feb 17, 2014 10:13 pm
by Maryna Brodina

Thank you for update! Glad it's working!