Forum Discussion
Hi Jake,
I really appreciate your help. I still don't have any luck on this. I have tried jQuery event delegation too, but its still not executing the script. I have posted my complete code below.
<style> #search .SearchForm { visibility: visible !important; } .lia-button-searchForm-action{ visibility: hidden; } .lia-search-input-message{ padding: 0px 0px 0px 10px !important; border-radius: 5px !important; } .lia-component-common-widget-search-form .lia-search-input-wrapper .search-input{ height: 40px !important; } .lia-component-common-widget-search-form{ padding: 0px !important; } </style> <script> $(document).ready(function(){ $('[name="messageSearchField"]').attr('placeholder','Enter a Subject'); }); </script> <div id="search"> <table style="width:100%"> <tbody> <tr> <td width="10%"><label class="required" id="ot_subject">Subject:</label></td> <td><label id="subjectErrorMessage" style="color:red" hidden="true">Subject cannot be blank</label></td> </tr> </tbody> </table> <@component id="common.widget.search-form" hideGranularity="true" defaultToCommunity="false"/> </div> <@liaAddScript> ;(function($){ $(document).on('click', 'a.lia-link-navigation.lia-js-autocomplete-list-item-link.lia-autocomplete-message-list-item-link.lia-component-forums-auto-complete-message-list-item', function(event){ event.preventDefault(); console.log("This worked!"); window.open($(this).attr('href'), '_blank'); }); })(LITHIUM.jQuery); </@liaAddScript>
I have created a custom search suggestion component using Standard Search form and consuming the same in other pages.
Please let me know if i have done something wrong with this code.
Thanks
Unfortunately, after doing some digging ... any jQuery or JS expert feel free to correct me ... there is no way to attach an event to the autosuggestion anchors.
The only way that you could do that is recreating the component yourself from scratch. Which I have done but ours is customised to how we need it.
The last thing while we are on this subject that I can think of that could work, would be trying to intercept the returned results and creating the autosuggest anchor tags themselves with the target="_blank" attribute. This would be a giant task and I don't know enough to tell you that it would work.
Related Content
- 2 years ago
- 2 years ago
- 2 years ago