Discussions

Expand all | Collapse all

Use Multiple Javascript Pages in a single form

  • 1.  Use Multiple Javascript Pages in a single form

    Posted 06-27-2019 22:23
    I have a table with one Code page ("page1.js") in the field "page1" (Formula - Rich Text)working just fine. I want to add another "page2.js" in the field "page2" for a different purpose in the same table form. 

    The problem I'm facing is only one of these code pages are loading depending on their position in the form. So the top order field with the code page in it will load but the bottom order field with the code page will not load. 

    Following is the way I'm trying to access the Javascript Code Page into the table which is working if loaded one at a time. 

    Field         Formula - Rich Text
    Page1      [iol] & "page1.js" & [/iol]
    Page2      [iol] & "page2.js" & [/iol]


    Please advise if I need to consider something before using two Javascripts like this or Is there any limitations with Quickbase. _

    Thank you.


  • 2.  RE: Use Multiple Javascript Pages in a single form

    Posted 06-28-2019 13:57
    Can you combine your JS pages together and have it invoke both functions within the same file? Whats the reasoning behind having two separate code pages and two separate iol? 

    I'm not familiar with a reason why having more than one iol would cause issues specifically. 

    Chayce Duncan | Director of Strategic Solutions
    (720) 739-1406 | chayceduncan@quandarycg.com
    Quandary Knowledge Base


  • 3.  RE: Use Multiple Javascript Pages in a single form

    Posted 06-28-2019 16:20
    Hello Chayce,

    Both of my scripts will have the Actions in it which are being triggered every time something changes on the webpage. So I think I can not load the second "page2.js" into "page1.js" as it will only execute one time and that's not what I want.

    I can use only one JS page and write all of the thousand lines of code in it for all the different purpose and that's a big "NO" from me as a developer (Unless QB is restricting us from using two JS in a single table/form). 

    Thank you for your thoughts.




  • 4.  RE: Use Multiple Javascript Pages in a single form

    Posted 06-28-2019 16:55
    Again - I don't know of any reason why you couldn't have more than 1 IOL - not sure if thats a Quick Base thing or a browser thing. Have you tested the code page outside of the IOL, or tried to console something out to see if its actually running - just not operating as expected?

    If both pages are fine and it is in fact something to do with the page running both scripts - without merging it into one massive code file - maybe consider leaving them as standalone - and create a page3.js file - in it just do a little $.getScript() and pull in your code pages into this page3.js - and then have a single IOL that runs page3.js

    Not the ideal solution - more of a workaround than a fix. Just thinking out loud

    Chayce Duncan | Director of Strategic Solutions
    (720) 739-1406 | chayceduncan@quandarycg.com
    Quandary Knowledge Base


  • 5.  RE: Use Multiple Javascript Pages in a single form

    Posted 06-28-2019 17:03
    I logged them both and they are working just fine. It's just for some reason it's not working together as I explained. 

    As long as creating "page3.js" concerns, don't you think it will be the same case as using "page2.js" into "page1.js". Let's assume that we can get the scripts working via $.getScript(), but will they be able to get the triggers from the webpage respectively? 


  • 6.  RE: Use Multiple Javascript Pages in a single form

    Posted 06-28-2019 19:10
    Hard to say for absolute certainty that it would be the same issue. If the root problem is just running two IOL functions - then no, I think doing a page3.js and doing nested $.getScripts() shouldn't be an issue. Since your running just a single js page and absorbing it all within a single IOL call - I don't see any issue there

    Chayce Duncan | Director of Strategic Solutions
    (720) 739-1406 | chayceduncan@quandarycg.com
    Quandary Knowledge Base


  • 7.  RE: Use Multiple Javascript Pages in a single form

    Posted 06-28-2019 19:12
    Okay, I'll give it a try.

    Thank you Chayce.


  • 8.  RE: Use Multiple Javascript Pages in a single form

    Posted 06-28-2019 19:14
    I'd be interested to hear if you are able to resolve either with the way discussed or if you come across a different alternative, if you don't mind reporting back in this thread with how you proceed. 

    Chayce Duncan | Director of Strategic Solutions
    (720) 739-1406 | chayceduncan@quandarycg.com
    Quandary Knowledge Base


  • 9.  RE: Use Multiple Javascript Pages in a single form

    Posted 06-28-2019 19:15
    Sure thing. I will report my findings in this report.


  • 10.  RE: Use Multiple Javascript Pages in a single form

    Posted 06-28-2019 20:38
    So loading the script "page2.js"  into the script "page1.js" worked just fine with click and change events. So basically the approach here would be to create a Main.js file and load all other javascript pages with $.getScript("URL") as Chayce Duncan suggested.

    Though, I want to outline one silly mistake that I made with URL so no one else had to go through it.

    - Make sure to load script as "https://yourdomain.quickbase.com/db/bnnp8ryeg?a=dbpage&pageID=71" and don't copy and paste the page link as it contains "a=pageedit" which we don't need. What we want is "a=dbpage".
    - Please follow the link below for more instructions on loading pages in QB.
    https://community.quickbase.com/quickbase/topics/how-to-create-javascript-pages

    Please feel free to give your thoughts.

    PS: Not the answer that I was looking for but this is going to work just fine.