Page 1 of 1

DOM selection

PostPosted: Wed Feb 04, 2015 3:15 am
by luishp
┬┐How to access a DOM element through JavaScript?
I have try $("#elementID") and document.getElementById("elementID") but i'm not sure this is correct in AngularJS.
The SetAttribute command seems not to work for objects out of the current page and properties values are reseted whenever you leave and return to the current page.
Thanks!

Re: DOM selection

PostPosted: Wed Feb 04, 2015 12:29 pm
by Neosoft Support
This seemed to work for me:

$( '#Paragraph1' ).html( '<p>Hello</p>' );

The object ID '#Paragraph1' is case sensitive.

You can also use the angular.element function to access the DOM. For example:

angular.element( '#Paragraph1' ).html( '<p>Hello</p>' );

This didn't seem to work any differently from the JQuery method above.

Re: DOM selection

PostPosted: Thu Feb 05, 2015 2:05 am
by luishp
Thanks Dave for your answer.

Any of these seems to work but only when Image1 is in the current page:

Code: Select all
SetAttribute #Image1 "width" "120px"
document.getElementById("Image1").style.width="120px";
$("#Image1" ).css("width","120px");
angular.element("#Image1").css("width","120px");


But if you leave the page "GotoNextPage" and then enter again "GotoPrevPage", the attribute "width" will be reseted to its original value.
I'm not sure if this is a bug or not.
Is there anyway right now to permanently change an object attribute even outside the current page?

Re: DOM selection

PostPosted: Thu Feb 05, 2015 12:00 pm
by Neosoft Support
Is there anyway right now to permanently change an object attribute even outside the current page?


There isn't a solution in the current version, but I think there will be soon. The problem is that only objects on the current page are loaded into memory, so only those objects can be modified. When you leave the current page its objects are removed from memory and the new page's objects loaded in its place.

Re: DOM selection

PostPosted: Thu Feb 05, 2015 1:11 pm
by Gaev
Dave:

There isn't a solution in the current version, but I think there will be soon.

Will there be event sections in NeoAppBuilder for "Page Enter" and "Page Exit" ... like we have with NeoBook ?

If so, an interim solution would be for developers to save/restore such properties by themselves.

Later, a generic command/function can be developed ... so users can save/restore all properties of named objects with just one line of code.

Re: DOM selection

PostPosted: Fri Feb 06, 2015 10:47 am
by Neosoft Support
Will there be event sections in NeoAppBuilder for "Page Enter" and "Page Exit" ... like we have with NeoBook ?


Clicking on the page background (not on an object) will select the page. When the page is selected, the code editor will show events for page enter and page exit.

Re: DOM selection

PostPosted: Fri Feb 06, 2015 2:04 pm
by Gaev
Dave:

Clicking on the page background (not on an object) will select the page. When the page is selected, the code editor will show events for page enter and page exit.

Sorry, I was a bit quick on the draw ... should have checked before posting.

However, please see my posting at http://www.neosoftware.com/webissues/client/index.php?issue=18 ... where I observed ...
@Dave: When I "Run in Firefox" ... and then return to Design Mode ... the entered code for this event section does not display any more ... but if I navigate to another page ... and return to it, all is well !!!

Re: DOM selection

PostPosted: Sat Feb 07, 2015 11:05 am
by Neosoft Support
@Dave: When I "Run in Firefox" ... and then return to Design Mode ... the entered code for this event section does not display any more ... but if I navigate to another page ... and return to it, all is well !!!


The code in the page enter action disappears? Make sure the page is still selected. It may be that when you return from FireFox you're clicking on the background and un-selecting the page.

Re: DOM selection

PostPosted: Sat Feb 07, 2015 12:07 pm
by Gaev
Dave:

Make sure the page is still selected. It may be that when you return from FireFox you're clicking on the background and un-selecting the page.

That was it ... I thought that clicking on the background would ALWAYS select the Page object ... but from the handle bars/circles, it looks like this selection is toggled on/off with each click.