View/Page override
No edit summary
(Automatically adding template at the end of the page.)
 
(3 intermediate revisions by 2 users not shown)
Line 1: Line 1:
You can write your on cshtml to override the built in page renderer of Turnkey.
You can write your own cshtml to override the built-in page renderer in Turnkey.


===== Accessing the angular $scope in javascipt code called from inside a page =====
===== Accessing the Angular $scope in Javascipt Code Called Inside a Page =====
If used in an element, this code gets the current scope.
If used in an element, this code gets the current scope.
  angular.element(this).scope()
  angular.element(this).scope()
From "anywhere" this will get the scope of the current element
This will get the scope of the current element from "anywhere"
  angular.element($0).scope()
  angular.element($0).scope()


===== Example with delayed calling of functions =====
===== An Example with Delayed Calling of Functions =====
For example, using this in an onclick event (NOT ng-click) will call the function DelayedSave in the script tag of the overridden page.
For example, using this in an on-click event (NOT ng-click) will call the function DelayedSave in the script tag of the overridden page.


Note that a button can have both an ng-click and a onclick defined and both will be called.
Note that a button can have both an ng-click and an on-click defined and both will be called.
  onclick="DelayedSave(angular.element(this).scope())"
  onclick="DelayedSave(angular.element(this).scope())"
This example calls an action in the ViewModel called LazySave to save changes 2 seconds after the action with the onclick is executed.
This example calls an action in the ViewModel called LazySave to save changes 2 seconds after the action with the on-click is executed.
  <script>
  <script>
   function DelayedSave(scope) {
   function DelayedSave(scope) {
Line 20: Line 20:
   };
   };
  </script>
  </script>
More reading on how to make on-click work in an angular page
Read more on how to make on-click work on an angular page: [[Ng-click ( ngClick ) not working]]


[[Ng-click ( ngClick ) not working]]
See also [[EXT Components]] for overriding only a ViewModel attribute with your own code.
 
Se also [[EXT Components]] for overriding only a viewmodel attribute with your own code.
[[Category:MDriven Turnkey]]
[[Category:MDriven Turnkey]]
[[Category:View Model]]
[[Category:View Model]]
{{Edited|July|12|2024}}

Latest revision as of 15:49, 10 February 2024

You can write your own cshtml to override the built-in page renderer in Turnkey.

Accessing the Angular $scope in Javascipt Code Called Inside a Page

If used in an element, this code gets the current scope.

angular.element(this).scope()

This will get the scope of the current element from "anywhere"

angular.element($0).scope()
An Example with Delayed Calling of Functions

For example, using this in an on-click event (NOT ng-click) will call the function DelayedSave in the script tag of the overridden page.

Note that a button can have both an ng-click and an on-click defined and both will be called.

onclick="DelayedSave(angular.element(this).scope())"

This example calls an action in the ViewModel called LazySave to save changes 2 seconds after the action with the on-click is executed.

<script>
  function DelayedSave(scope) {
  setTimeout(function () {
      scope.StreamingViewModelClient.CallServerAction('JournalSeeker', 'LazySave');
    }, 2000);
  };
</script>

Read more on how to make on-click work on an angular page: Ng-click ( ngClick ) not working

See also EXT Components for overriding only a ViewModel attribute with your own code.

This page was edited 96 days ago on 02/10/2024. What links here