TYPESCRIPT - Update css of iframe by jquery

From GUILLARD WIKI
Revision as of 14:34, 20 April 2018 by Guillard (talk | contribs) (Created page with "In your .ts file: <syntaxhighlight lang="javascript"> private mainFunction(): void { this.waitForEl('#iframeABC', '.comment', 0, () => { $('#iframeABC').c...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

In your .ts file:

<syntaxhighlight lang="javascript">

 private mainFunction(): void {
     this.waitForEl('#iframeABC', '.comment', 0, () => {
         $('#iframeABC').contents().find('.comment').css({
             'border-left': '0px',
             'border-right': '0px'
         });
         console.log('Updated css iframe');
     });
 }   
 private waitForEl(iframe: string, selector: string, count: number, callback: () => void): void {
   if (PaylineUtils.jQuery(iframe).contents().find(selector).length > 0) {
     callback();
   } else {
     setTimeout(() => {
       count++;
       if (count <= 10) {
         this.waitForEl(iframe, selector, count, callback);
       } else {
         return;
       }
     }, 1000);
   }
 }


</syntaxhighligh>