Kateryna Grynko
Posts: 0
Joined: Thu Nov 15, 2012 9:13 am

list empty returns javascript error

Testing... I'll update.

Kateryna Grynko
Posts: 0
Joined: Thu Nov 15, 2012 9:13 am

list empty returns javascript error

Could you please give us a public link to your app? We can't reproduce the problem.

w
Posts: 0
Joined: Tue Mar 26, 2013 12:30 pm

list empty returns javascript error

I narrowed it down a bit. It seems that the problem does not occur on the Appery('list').empty() itself , but afterwards when the list is populated from a service mapping.

If I DON'T do the Appery('list').empty() first, then there is no problem and the list shows without error.
If I do a Appery('list').empty() BEFORE executing the service that maps to the list, then the error is there!

w
Posts: 0
Joined: Tue Mar 26, 2013 12:30 pm

list empty returns javascript error

Yes, now I am sure there is an bug.

I reproduced the error on a complete blank page with just 1 selectmenu and 1 service. The service response is mapped to the selectmenu.

On the page show event: do Appery('list').empty()
Then another page show event: invoke the service. (make sure the invoke service event is AFTER the Appery('list').empty())

You will see that the error is there.

There is no error if you do a .empty() in the success event of the service, of if you do a .empty() without invoking the service that is mapped to the selectmenu.

Since I had the error also with a list, I suspect that lists AND selectmenus are susceptible to this bug.

w
Posts: 0
Joined: Tue Mar 26, 2013 12:30 pm

list empty returns javascript error

If you discover the bug, could you please think of a workaround, because the empty() list before the service invoke is critical to my app...

Kateryna Grynko
Posts: 0
Joined: Thu Nov 15, 2012 9:13 am

list empty returns javascript error

Be sure, we will let you know asap.

Maryna Brodina
Posts: 0
Joined: Thu Apr 05, 2012 7:27 am

list empty returns javascript error

Hello! It's not a bug. You need to map parameters to some components. For Select there is an empty option code<option value="" rerender="mobileselectmenuName" dsid="mobileselectmenuName-0" data-placeholder="true"><&#47;option>/code.
In List there is a hidden item, based on this item new items create when you map. You can save these hidden elements on page Show event (for example in localStorage). Then after empty() add saved elements, for example for Select if it's empty at the beginning. On page Show run JS:
codevar defaultOptionFormobileselectmenuName = Appery("mobileselectmenuName")&#46;html();
localStorage&#46;setItem("defaultOptionFormobileselectmenuName", defaultOptionFormobileselectmenuName);/code

After codeAppery("mobileselectmenuName")&#46;empty();/code should be added codeAppery("mobileselectmenuName")&#46;append(localStorage&#46;getItem("defaultOptionFormobileselectmenuName"));/code

w
Posts: 0
Joined: Tue Mar 26, 2013 12:30 pm

list empty returns javascript error

Then why is it working when, after an empty() , I manually append options, but it is not working when the selectmenu is mapped to from a service afterwards?

I cannot use your Appery('mobileselectmenuName').html() because sometimes the list has already real values, which is the exact reason why I want to use the empty() ...

w
Posts: 0
Joined: Tue Mar 26, 2013 12:30 pm

list empty returns javascript error

How can I select this hidden element when the list already has real values? Because Appery('listname').children(':first') gives me the first REAL child, not the hidden element option.

Furthermore, I did what you suggested for the LIST. On first page load I do:

localStorage.setItem("listItemStart", "Appery('list').html());

Then further I do: Appery('list').empty(); Appery('list'). append(localStorage.getItem("listItemStart"));
Then service.execute, as normal.

On the page, the list is not showing. But I can see in the source html that all list items are there, but they have a display:none , just as the template hidden 1st item used to have.

Any ideas?

Return to “Issues”