Page 1 of 1

Calling a CustomDialog using Javascript ?

PostPosted: Mon Mar 09, 2015 9:16 pm
by David de Argentina
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

Re: Calling a CustomDialog using Javascript ?

PostPosted: Tue Mar 10, 2015 1:15 am
by luishp
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.

Re: Calling a CustomDialog using Javascript ?

PostPosted: Tue Mar 10, 2015 9:30 am
by David de Argentina
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

Re: Calling a CustomDialog using Javascript ?

PostPosted: Tue Mar 10, 2015 11:41 am
by Neosoft Support
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' );