All Apps and Add-ons

KV Store Tutorial - Delete Button Fails in Firefox

IngloriousSplun
Communicator

I'm creating some forms that rely on the ability to delete or update an individual record in a KV store. Walking through the KV store tutorial, Step 5 for creating the DELETE functionality does not seem to work. Does anyone with experience using KV stores know what the issue could be? I've copied the code verbatim from the tutorial. I can fully manipulate the records using curl, however, using the method described in the tutorial fails without an error that I can find.

        // 
        // DELETE BUTTON
        //

        // Call this function when the Delete Record button is clicked
        $("#deleteRecord").click(function() {
            // Get the value of the key ID field
            var tokens = mvc.Components.getInstance("default");
            var form_keyid = tokens.get("KeyID");

            // Delete the record that corresponds to the key ID using
            // the del method to send a DELETE request
            // to the storage/collections/data/{collection}/ endpoint
            service.del("storage/collections/data/mycollection/" + encodeURIComponent(form_keyid))
                .done(function() { 
                    // Run the search again to update the table
                    search1.startSearch(); 
                });
        }); 
1 Solution

dgladkikh_splun
Splunk Employee
Splunk Employee

Ok, I found the issue in tutorial, add

return false;

as the last statement of deleteRecord button handler, so it should be like

$("#deleteRecord").click(function() {
             // Get the value of the key ID field
             var tokens = mvc.Components.getInstance("default");
             var form_keyid = tokens.get("KeyID");

             // Delete the record that corresponds to the key ID using
             // the del method to send a DELETE request
             // to the storage/collections/data/{collection}/ endpoint
             service.del("storage/collections/data/mycollection/" + encodeURIComponent(form_keyid))
                 .done(function() { 
                     // Run the search again to update the table
                     search1.startSearch(); 
                 });
             return false;
         }); 

This will prevent browser to submit the page (and do refresh of the page) which prevents current page to submit AJAX call before page reload.

View solution in original post

dgladkikh_splun
Splunk Employee
Splunk Employee

Ok, I found the issue in tutorial, add

return false;

as the last statement of deleteRecord button handler, so it should be like

$("#deleteRecord").click(function() {
             // Get the value of the key ID field
             var tokens = mvc.Components.getInstance("default");
             var form_keyid = tokens.get("KeyID");

             // Delete the record that corresponds to the key ID using
             // the del method to send a DELETE request
             // to the storage/collections/data/{collection}/ endpoint
             service.del("storage/collections/data/mycollection/" + encodeURIComponent(form_keyid))
                 .done(function() { 
                     // Run the search again to update the table
                     search1.startSearch(); 
                 });
             return false;
         }); 

This will prevent browser to submit the page (and do refresh of the page) which prevents current page to submit AJAX call before page reload.

dgladkikh_splun
Splunk Employee
Splunk Employee

Which version of Firefox are you using? I just verified with 36.0.1 and 38.0a2 (2015-03-10) for Mac - works fine for me.
Could you just try to use this page from latest step and see if it works? http://dev.splunk.com/view/SP-CAAAEZ2

IngloriousSplun
Communicator

I'm using 35.0.1 on Windows 7, and I copied the code from that link verbatim and I'm still having the issue where records persist when I try to delete them.

0 Karma

dgladkikh_splun
Splunk Employee
Splunk Employee

Could you debug it?

0 Karma

IngloriousSplun
Communicator

I looked through the developer console during the process and I didn't see any errors. I didn't see the request go out for the delete operation either, but I'm not sure whether I should since its making a REST call on the local system.

0 Karma
Get Updates on the Splunk Community!

What's new in Splunk Cloud Platform 9.1.2312?

Hi Splunky people! We are excited to share the newest updates in Splunk Cloud Platform 9.1.2312! Analysts can ...

What’s New in Splunk Security Essentials 3.8.0?

Splunk Security Essentials (SSE) is an app that can amplify the power of your existing Splunk Cloud Platform, ...

Let’s Get You Certified – Vegas-Style at .conf24

Are you ready to level up your Splunk game? Then, let’s get you certified live at .conf24 – our annual user ...