Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8089733
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T19:29:48+00:00 2026-06-05T19:29:48+00:00

I am trying to interact with a javascript api (bare in mind I have

  • 0

I am trying to interact with a javascript api (bare in mind I have never done this before). An example of what I am attempting to work with is here:

SearchSpring.Catalog.init({
    leaveInitialResults : true,
    facets : '.leftNav',
    results : '#results',
    result_layout: 'list',
    results_per_page : 12,
    layout: 'top',
    loadCSS: false,
    filters: {
        color: ['Blue']
    },
    backgroundFilters: {
        category: ['Shirt', 'Shoes'],
        department: ['Mens']
    },
    maxFacets: 5,
    maxFacetOptions: 10,
    sortText: 'Sort By ',
    sortType: 'dropdown',
    filterText: 'Refine Search Results',
    previousText: 'Previous',
    scrollType: 'scroll',
    scrollTo: 'body',
    backgroundSortField: 'price',
    backgroundSortDir: 'desc',
    compareText: 'Compare Items',
    summaryText: 'Current Filters',
    showSummary: true,
    subSearchText: 'Subsearch:',
    showSubSearch: true,
    forwardSingle: false,
    afterResultsChange: function() { $('.pagination').hide(); },
    filterData: function(data) { console.debug(data); }
});

In the example I want to add a “backgroundFilter” to this with a value:

var cat="MyNewCategory";
cat.value="ANewValue;

How would I add this category and value to the backgroundFilters: listed above?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T19:29:49+00:00Added an answer on June 5, 2026 at 7:29 pm

    This is a very common framework initialization pattern when working with frameworks.

    Your example code is passing a JavaScript Object {} as a parameter into a function () that is called init.

    Taking out all definitions the pattern looks like this:

    SomeFramework.frameworkFunction({});
    

    In the above code the {} is an empty object used for initialization. There are two ways that you can work with that object in practice.

    Regarding your first code snippet, you can add code into that ‘object literal’.

    backgroundFilters: {
    category: [‘Shirt’, ‘Shoes’],
    department: [‘Mens’],
    cat: [‘My value’]
    },

    Notice the added comma, this is an important tripping point. This may or may not fit your needs, depending on a few factors.

    Regarding your second code snippet, you can apply members to JavaScript objects at runtime. What I mean is, your var cat can be added to the anonymous object-literal that is being passed in. Hard to say, but a simple concept. Here is how:

    //Say this is initialized in some separate way. //There is a bug here I'll describe later.
    var cat="MyNewCategory";
    cat.value="ANewValue";
    
    //Extract and name the initialization object. It is verbatim at this point.
    var initObject = {
        leaveInitialResults : true,
        facets : '.leftNav',
        results : '#results',
        result_layout: 'list',
        results_per_page : 12,
        layout: 'top',
        loadCSS: false,
        filters: {
            color: ['Blue']
        },
        backgroundFilters: {
            category: ['Shirt', 'Shoes'],
            department: ['Mens']
        },
        maxFacets: 5,
        maxFacetOptions: 10,
        sortText: 'Sort By ',
        sortType: 'dropdown',
        filterText: 'Refine Search Results',
        previousText: 'Previous',
        scrollType: 'scroll',
        scrollTo: 'body',
        backgroundSortField: 'price',
        backgroundSortDir: 'desc',
        compareText: 'Compare Items',
        summaryText: 'Current Filters',
        showSummary: true,
        subSearchText: 'Subsearch:',
        showSubSearch: true,
        forwardSingle: false,
        afterResultsChange: function() { $('.pagination').hide(); },
        filterData: function(data) { console.debug(data); }
    };
    
    //Now we can add variables (and functions) dynamically at runtime.
    initObject.cat = cat;
    
    //And pass them into the framework initialization in a separated way.
    SearchSpring.Catalog.init(initObject);
    

    Now for the bug. I don’t know the solution because I do not know what it is intended to do, but I can point out what is potentially incorrect.

    var cat=”MyNewCategory”;
    cat.value=”ANewValue;

    This code is: 1 creating a String Object called cat. 2 changing the value to a new string.
    I do not think this is what you really want.

    To add a new backgroundFilter, in the separated way above, it would be:

    initObject.backgroundFilters.cat = ['A', 'B'];
    
    //Line above would give you this type of definition within the initObject (at runtime):
            backgroundFilters: {
                category: ['Shirt', 'Shoes'],
                department: ['Mens'],
                cat: ['A','B']
    
            },
    

    For this to work it will depend on what the framework is expecting regarding backgroundFilters.

    Hope that helps.
    All the best!
    Nash

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this code for an Android application I'm trying to create into interact
Here is what I am trying to accomplish. I have a form that uses
I have an array in Javascript that i am trying to pass to php.
I am trying to interact with another process in Java. It goes like this...
I have been trying to do this for ages, even looked at: C# WebBrowser
I'm trying to interact with the Siebel Communications activex web application.We have an existing
I'm trying to make a Java applet interact through javascript in its enclosing environment.
I am sure this must have been answered before but I cannot find a
I'm trying to interact with the unofficial Android API: http://code.google.com/p/android-market-api/ . It includes two
I'm trying to interact with an application over the network which uses a simple

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.