Dashboards & Visualizations

Calling Js from Anchor <a> tag in splunk

AlokPanday
Loves-to-Learn Lots

Hi,

I need to call Js from <a> achor tag can someone please help.

 

<div id="showMoreRecords" align="right">
<a>Show More Records</a>
</div>

 

 

JS file code:

require([
'underscore',
'backbone',
'../app/monitorPro/components/ModalView',
'splunkjs/mvc',
'splunkjs/mvc/searchmanager',
'splunkjs/mvc/simplexml/ready!'
], function(_, Backbone, ModalView, mvc, SearchManager) {


var order = mvc.Components.get("showMoreRecords"); // getting error here
var tokens = mvc.Components.getInstance("submitted");
var poNumber = tokens.get("PONumber_ord");


var detailSearch = new SearchManager({
id: "detailSearch",
earliest_time: "0",
latest_time: "",
preview: true,
cache: false,
search: 'index=testIndex source="testsource" PONumber=$PONumber_ord$ |table PONumber,CustomerName,RequestDate,shipperTimestamp'
}, {tokens: true, tokenNamespace: "submitted"});

order.on("click", function(e) {
e.preventDefault();

var modal = new ModalView({ title: poNumber, search: detailSearch });
modal.show();


});

});

Labels (1)
0 Karma

kamlesh_vaghela
SplunkTrust
SplunkTrust

@AlokPanday 

Update your code like this.

<div align="right">
<a id="showMoreRecords">Show More Records</a>
</div>

 

require([
    'underscore',
    'backbone',
    '../app/monitorPro/components/ModalView',
    'splunkjs/mvc',
    'splunkjs/mvc/searchmanager',
    'splunkjs/mvc/simplexml/ready!'
], function(_, Backbone, ModalView, mvc, SearchManager) {


    // var order = mvc.Components.get("showMoreRecords"); // getting error here
    var tokens = mvc.Components.getInstance("submitted");
    var poNumber = tokens.get("PONumber_ord");


    var detailSearch = new SearchManager({
        id: "detailSearch",
        earliest_time: "0",
        latest_time: "",
        preview: true,
        cache: false,
        search: 'index=testIndex source="testsource" PONumber=$PONumber_ord$ |table PONumber,CustomerName,RequestDate,shipperTimestamp'
    }, { tokens: true, tokenNamespace: "submitted" });

    $('#showMoreRecords').on("click", function() {
        e.preventDefault();

        var modal = new ModalView({ title: poNumber, search: detailSearch });
        modal.show();


    });

});

 

I hope this will help you.

Thanks
KV
▄︻̷̿┻̿═━一   😉

If any of my reply helps you to solve the problem Or gain knowledge, an upvote would be appreciated.

0 Karma

AlokPanday
Loves-to-Learn Lots

 thanks for the help.

Tags (1)
0 Karma
Get Updates on the Splunk Community!

Streamline Data Ingestion With Deployment Server Essentials

REGISTER NOW!Every day the list of sources Admins are responsible for gets bigger and bigger, often making the ...

Remediate Threats Faster and Simplify Investigations With Splunk Enterprise Security ...

REGISTER NOW!Join us for a Tech Talk around our latest release of Splunk Enterprise Security 7.2! We’ll walk ...

Introduction to Splunk AI

WATCH NOWHow are you using AI in Splunk? Whether you see AI as a threat or opportunity, AI is here to stay. ...