Source language: Translate to:

Calling a CustomDialog using Javascript ?

General questions about NeoAppBuilder - our rapid application development tool for building HTML5, web and mobile apps.

Moderator: Neosoft Support

Calling a CustomDialog using Javascript ?

Postby David de Argentina » Mon Mar 09, 2015 9:16 pm

Hi all,

I have a table with contacts.
All data are well displayed.
I created a function that every time a cell ( a contact ) is touched (clicked) an alertbox is displayed.

The function is:

Code: Select all
<script type="text/javascript">
function muestra(cual) {
    var c = "C" + cual;
    var b = "B" + cual;
    var quien = document.getElementById(b).innerHTML;
    var tel = document.getElementById(c).innerHTML;
    alert('Telephone: ' + tel);
  }
</script>


All works fine.
Now, I just created a very nice CustomDialog.
Is possible open a CustomDialog using javascript, in order to replace the basic "alert()" of javascript ?

Any ideas ?
Thanks in advance,
David de Argentina
User avatar
David de Argentina
 
Posts: 1562
Joined: Mon Apr 04, 2005 4:13 pm
Location: Buenos Aires, Argentina

Re: Calling a CustomDialog using Javascript ?

Postby luishp » Tue Mar 10, 2015 1:15 am

It is possible to call any NeoAppBuilder subroutine or command form JavaScript.
Just use this sintax:

Code: Select all
$scope.NeoAppBuilderCommand(param1,param2,...);


Change NeoAppBuilderCommand for the NeoAppBuilder subroutine or command name
Use "param" to send string parameters.
Luis Hernández - SinLios Soluciones Digitales
http://sinlios.com
User avatar
luishp
 
Posts: 361
Joined: Wed May 23, 2007 10:17 am
Location: Spain

Re: Calling a CustomDialog using Javascript ?

Postby David de Argentina » Tue Mar 10, 2015 9:30 am

Thanks Luis,

My NeoAppBuilder function is called "ShowDlg".

Function has the following line:

Code: Select all
OpenDialog "NewDialog"


The script within the php that should fire the "ShowDlg" function is:

Code: Select all
echo '<script type="text/javascript">';
echo 'function vercual() { ';
echo '$scope.ShowDlg();';
echo '}';
echo '</script>';


Data is retreived fine, but when i clicked each row, i receive this error message:

" Uncaught ReferenceError: $scope is not defined "

Any ideas ?

Thanks again,
David de Argentina
User avatar
David de Argentina
 
Posts: 1562
Joined: Mon Apr 04, 2005 4:13 pm
Location: Buenos Aires, Argentina

Re: Calling a CustomDialog using Javascript ?

Postby Neosoft Support » Tue Mar 10, 2015 11:41 am

This works:

BeginJS
$scope.OpenDialog( 'DialogID' );
EndJS

Because you're placing JavaScript code in a <script> tag it's outside the scope of the app. That means you don't have access to "$scope" and the functions that are part of the app. Try creating a custom subroutine and placing your JavaScript code there instead.

If, for some reason, you absolutely need to use a script tag, you may be able to access the app's $scope like this:

var scp = angular.element(document.body).scope();
scp.OpenDialog( 'DialogID' );
NeoSoft Support
Neosoft Support
NeoSoft Team
 
Posts: 5605
Joined: Thu Mar 31, 2005 10:48 pm
Location: Oregon, USA


Return to General NeoAppBuilder Discussion

Who is online

Users browsing this forum: No registered users and 1 guest

cron