Intercepting Add/Edit Button on Block

Permalink
The block I'm creating needs to run some JavaScript before the "Add" button does its thing. I was hoping that I could somehow commandeer the Add button and have it instead run my js function then call the normal procedure at the end of my function.

Lemme know if I need to clarify, thanks.

phatworks
 
codingpenguins replied on at Permalink Reply
Before the add button is processed the auto.js file runs (which usually does the field validations, but I do not see any problem with adding some javascript functions to this file to run. Hope this helps.
phatworks replied on at Permalink Reply
phatworks
How do I go about modifying auto.js? Is it currently empty if I don't have it in my block folder? Or, is there a default file that is used that I need to copy into my block folder and modify? Or, do I just create an auto.js for my block folder and then overload some of the functions?
codingpenguins replied on at Permalink Best Answer Reply
you just create it and add it in the block folder (just name it "auto.js"). Heres one of my example:
function ccmValidateBlockForm() {
   if (missingRequiredNumber('eventID')) {
      ccm_addError('You must enter a number for the Event ID.');
   }
   if (missingRequiredNumber('width')) {
      ccm_addError('You must enter a number for the feed width.');
   }
   if (missingRequiredNumber('feednum')) {
      ccm_addError('You must enter a number for the max number of comments to display.');
   }
   if (missingRequiredNumber('appid')) {
      ccm_addError('You must enter a number for the App ID.');
   }
   return false;
}


Edit:
Here is an example that I found and based on the example above and used. Not sure where it is from but I believe I made it simple:
var tags ={
   init:function(){      
      this.tabSetup();
   },   
   tabSetup: function(){
      $('ul#ccm-tags-tabs li a').each( function(num,el){ 
         el.onclick=function(){
            var pane = this.id.replace('ccm-tags-tab-','');
            tags.showPane(pane);
         }
      });      
   },
   showPane:function(pane){
      $('ul#ccm-tags-tabs li').each(function(num,el){ $(el).removeClass('ccm-nav-active') });
      $(document.getElementById('ccm-tags-tab-'+pane).parentNode).addClass('ccm-nav-active');


Don't quote me on this but this is a core method from ccmValidateBlockForm gets called on a submit where I would add my own functions above in the tags above.

Anymore examples, let me know