1

I just created a lightning component that calls a server side apex class to generate a token in order to query an external service and show search results. When I load the component using the app preview from the developer console, everything works fine, however, when I use the component in a lightning app and load it from a lightning app home page, it starts loading indefinitely, and a quick side note, this would not be appreciated by someone who suffers from epilepsy.

My main component loads the scripts from my static resources, then I call the controller function afterScriptsLoaded along with its helper. Any Idea why this might be happening?

app.cmp

<aura:component implements="flexipage:availableForAllPageTypes" controller="ApexTestWrapper" >
<ltng:require styles="{!$Resource.Namespace__Script1 + '/css/someCss.css'}"
 scripts="{!join(',',
          $Resource.Namespace__Script2+ '/js/SomeJs.min.js',
        $Resource.Namespace__Script3+ '/js/MoreJs.Dependencies.js',
        $Resource.Namespace__Script4+ '/js/templates/templatesNew.js')}"

 afterScriptsLoaded="{!c.load}"/>

  <body id="search" class='SearchInterface' data-enable-history="true" data-design="new">
      <div class="tab-section">
... More html
  </body>
</aura:component>

appcontroller.js

({
load : function(component, event, helper) {

        // getToken is the name of the Apex method that will be executed.
        var action = component.get('c.getToken');
        // The response will contain the token.
        action.setCallback(this, function(response){
            if(response.getState() == 'SUCCESS') {
                 var searchToken = response.getReturnValue();
                 helper.success(searchToken)
            }
        })
        // Queue the action using the framework available methods.
        $A.enqueueAction(action); 
    }
})

apphelper.js

({
success : function(searchToken) {
      ConnectTo.SearchEndpoint.endpoints['default'] = new The.SearchEndpoint({
        restUri: 'https://searchUri/rest/search',
         accessToken: searchToken
          
       });
    var theElement = document.getElementById("search");  
        Framework.init(theElement);
}
})

I also noted the following, when I do load the app (then the horrible reloading blinking starts), and then click on Home, my app loads, the tab doesn't change to the home page and everything suddenly is fine...(until I reload the page and the experience repeats itself)

enter image description here

occasionally, while switching tabs, the home tab will stick no matter what until i reload the page: enter image description here

I am under the impression that this has something to do with the both frameworks (lightning and the one I am using) trying to append data to the URL , since when I switch subtabs in my app, it does a query and adds

t=Case&sort=relevancy

to the URL, while the lightning framework tries to add something like this:

a:t=1490311116404

when I click a subtab this is my url: enter image description here

How could I resolve this and avoid this horrible light show.

Thanks!

fyi: the framework I am using is available here: https://github.com/coveo/search-ui

2

Every time I submitted a new query the fragment identifier (or hash) portion of the URL was being updated, in order to disable this, I had to set the CoveoSearchInterface enableHistory option to false:

      <body id="search" class='CoveoSearchInterface' data-enable-history="false" data-design="new">

as mentioned in the frameworks documentation here

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.