Backbone Local Storage “undefined is not a function”

I’m stumped here. I’m loading my scripts in the correct order, as confirmed by viewing source and I’m still getting this error in console:

 app.TodoList = Backbone.Collection.extend({
    model: app.Todo,
    localStorage: new Backbone.LocalStorage("backbone-todo")
    // Uncaught TypeError: undefined is not a function
 });

app.todoList = new app.TodoList();

Here’s how I’m queueing the scripts:

Read More
function av_one_load_scripts() {
    wp_register_script( 'backbone_localstorage', 'https://raw.github.com/jeromegn/Backbone.localStorage/master/backbone.localStorage-min.js', array( 'backbone' ) );
    wp_register_script( 'bb_one', get_stylesheet_directory_uri() . '/js/bb_one.js', array( 'jquery', 'backbone', 'backbone_localstorage' ) );

    wp_enqueue_script( 'backbone' );
    wp_enqueue_script( 'backbone_localstorage' );
    wp_enqueue_script( 'bb_one' );
}
add_action( 'wp_enqueue_scripts', 'av_one_load_scripts' );

This question revolved around an outdated Local Storage script, so I’m following example but still getting the error. Any ideas?

Related posts

Leave a Reply