Discussions

 View Only
  • 1.  U Can't Touch $(this)

    Posted 10-24-2018 03:10
    U Can't Touch $(this)

    I have been getting a lot of requests from QuickBase users asking if it is possible show, hide, duplicate or move various interface components such as buttons, links or form elements. Well of course you can and it often can be achieved in a few lines of script! 

    But you have to exercise some care and judgement as hip hop artist extraordinaire MC Hammer explains:

    U Can't Touch $(this)


    Hammer is a little short on technical details of how to accomplish this with QuickBase so I thought I would elaborate.

    When QuickBase renders a page some interface components may be hardcoded into the HTML source and during the lifetime of the page these components never change. This is the best case scenario because the script you inject can modify these components and there is no possibility of an undesirable interaction with native QuickBase behavior. A favorable example of this scenario is modifying a hardcoded button or link on a form. An unfavorable example might be attempting to modify a form through script that is actively controlled by form rules.

    Sometimes QuickBase dynamacally generates an interface component when the page loads. If QuickBase generates the component initially - but does not further modify it during the lifetime of the page - you can likewise use script to modify the component. However, you will have to wait for QuickBase to complete its initially rendering before you script kicks in. If QuickBase "manages" the component (say by dynamically hiding or showing it) you should avoid using script to modify the component to avoid conflicts.

    In most cases the script you inject can simply be wrapped in a IIFE (Immediately-invoked Function Expression):
    (function(){
      // your code here
    })();

    When you have to wait for QuickBase to finish building the interface components ,you may have to wrap your code in a standard jQuery ready handler:

    $(function(){
      // your code here
    })

    In yet other cases it may be necessary to use a Mutation Observer (or function override, object proxy, or some other advanced technique) to detect, react or intercept QuickBase's dynamically generated content. This sometimes comes up when users want to modify the appearance or behavior of native dialog boxes.