The JS observer

The JS observer is a component written in and utilizing JavaScript.

It basically works by saving the initial values of the form. When a user navigates away by clicking on a link, ull_js_observer compares the current form values with the initial one. If any changes are detected, it warns the user about unsaved changes.





There are three basic requirements for a warning to occur:

  • The user agent has JavaScript enabled
  • The page has unsaved changes
  • The user is leaving the page via a specially annotated link


Annotation of links


For the JS observer to work, links (which should trigger the modification checking process) have to be marked with a special option which is later processed into further JavaScript by the ull_link_to() function.


Example link:

ull_link_to('Homepage', '@homepage', 'ull_js_observer_confirm=true');


Developer information


Relevant code can be found in the following functions (all in ullHelper.php):

  • ull_link_to
  • _ull_to
  • ull_js_observer