Needs review
Project:
UberPOS
Version:
6.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
16 Feb 2011 at 15:17 UTC
Updated:
25 May 2011 at 06:46 UTC
Would it be possible to create a "hook" in uberpos_screen_ajax_succes to allow external modules to do some processing in JavaScript when the ajax call completes?
For example, would something like this be possible, or is there another way?
--- js/uberpos.js (revision 1090)
+++ js/uberpos.js (working copy)
@@ -3,6 +3,19 @@
Drupal.Uberpos.rowsPerScreen = 0;
Drupal.Uberpos.firstPass = true;
+// "hooks" for use in uberpos_screen_ajax_success
+if(! Drupal.Uberpos ){
+ Drupal.Uberpos = new Object();
+}
+if(! Drupal.Uberpos.ajax ){
+ Drupal.Uberpos.ajax = new Object();
+}
+if(! Drupal.Uberpos.ajax.jsonpostprocesshook ) {
+ Drupal.Uberpos.ajax.jsonpostprocesshook = [];
+};
+if(! Drupal.Uberpos.ajax.callcompletehook ) {
+ Drupal.Uberpos.ajax.callcompletehook = [];
+}
/*****************************************************************************
* Interface setup
*****************************************************************************/
@@ -300,6 +313,13 @@
* Includes products, line items, customer name. */
var result = Drupal.parseJson(data);
+ // json post processing hook
+ if(Drupal.Uberpos.ajax.jsonpostprocesshook) {
+ jQuery.each(Drupal.Uberpos.ajax.jsonpostprocesshook, function(i, postprocesshook){
+ postprocesshook.call(this, result);
+ });
+ };
+
Drupal.settings.uberpos.order_id = result['order_id'];
if(result['redirect']) {
@@ -351,6 +371,15 @@
$("input#edit-pos-input").focus();
}
+
+
+ // ajax call completion hook
+ if(Drupal.Uberpos.ajax.callcompletehook) {
+ jQuery.each(Drupal.Uberpos.ajax.callcompletehook, function(i, callcompletehook){
+ callcompletehook.call(this, result);
+ });
+ };
+
}
/**
@@ -366,5 +395,4 @@
function hide_uberpos_throbber() {
$('#uberpos-div-throbber').removeAttr('style').empty();
}
-
-
+;
Comments
Comment #1
rhmtts commentedBump. Could a core UberPOS developer please shine some light on this? We really like having this functionality available, but since it's not in UberPOS updating the module becomes somewhat of a pain.