Add web2py componentBegin event
Like the “w2p:componentComplete” event I added a while back, this is another event that I use in my website, and I thought it would be helpful to share it with others. This way, you can easily catch when a web2py component starts loading, and write a handler for whatever reason (in my case, determining when the user is navigating to a new page through a smooth loading function piggybacking off of the web2py component system)
This commit is contained in:
@@ -317,6 +317,7 @@
|
||||
'beforeSend': function (xhr, settings) {
|
||||
xhr.setRequestHeader('web2py-component-location', document.location);
|
||||
xhr.setRequestHeader('web2py-component-element', target);
|
||||
web2py.fire(element, 'w2p:componentBegin', [xhr, settings], target);
|
||||
return web2py.fire(element, 'ajax:beforeSend', [xhr, settings], target); //test a usecase, should stop here if returns false
|
||||
},
|
||||
'success': function (data, status, xhr) {
|
||||
|
||||
@@ -317,6 +317,7 @@
|
||||
'beforeSend': function (xhr, settings) {
|
||||
xhr.setRequestHeader('web2py-component-location', document.location);
|
||||
xhr.setRequestHeader('web2py-component-element', target);
|
||||
web2py.fire(element, 'w2p:componentBegin', [xhr, settings], target);
|
||||
return web2py.fire(element, 'ajax:beforeSend', [xhr, settings], target); //test a usecase, should stop here if returns false
|
||||
},
|
||||
'success': function (data, status, xhr) {
|
||||
|
||||
@@ -317,6 +317,7 @@
|
||||
'beforeSend': function (xhr, settings) {
|
||||
xhr.setRequestHeader('web2py-component-location', document.location);
|
||||
xhr.setRequestHeader('web2py-component-element', target);
|
||||
web2py.fire(element, 'w2p:componentBegin', [xhr, settings], target);
|
||||
return web2py.fire(element, 'ajax:beforeSend', [xhr, settings], target); //test a usecase, should stop here if returns false
|
||||
},
|
||||
'success': function (data, status, xhr) {
|
||||
|
||||
Reference in New Issue
Block a user