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

  • Home
  • SEARCH
  • 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 8994855
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T23:31:00+00:00 2026-06-15T23:31:00+00:00

This may be due to the fact that I’m new to JavaScript, and I

  • 0

This may be due to the fact that I’m new to JavaScript, and I just don’t know the correct syntax, but I can’t get my backbone model attributes to set on this Drop Event with this current syntax. Any suggestions? I’ve ran some tests with the handleDrop already and been able to set and save the model instance, but not with this current code in the handleDrop function.

Other suggestions regarding more efficient ways of writing this are always welcome 🙂

        //Set the data contained by the draggable elements
        var sourceID;
        var payloads = {
            poolpricedraggable: "poolprice",
            nonedraggable: "none"
        };

        //Set the data contained in the droppable elements
        var targetID;
        var targets = {
            panelone: "panel_one:",
            paneltwo: "panel_two:",
            panelthree: "panel_three:",
            panelfour: "panel_four:",
            panelfive: "panel_five:",
            panelsix: "panel_six:"              
        }
        
        //Create variable for all draggable & droppable elements
        var element = function(id) { return document.getElementById(id); }
        
        //Create event handlers for all drag and drop events
        function handleDragStart(event) {
            sourceID = this.id;
        }
        function handleDrop(event) {
            if(event.preventDefault) event.preventDefault();
            targetID = this.id;
            var dataattribute = targets[targetID];
            var datavalue = payloads[sourceID];
            var data = dataattribute + " " + datavalue;
          preflist.set(data);
            preflist.save();
        }
        
        //Add listeners for those events to the correct dashboard elements
        element('poolpricedraggable').addEventListener('dragstart', handleDragStart, false);

        element('panelone').addEventListener('drop', handleDrop, false);
        element('paneltwo').addEventListener('drop', handleDrop, false);
        element('panelthree').addEventListener('drop', handleDrop, false);
        element('panelfour').addEventListener('drop', handleDrop, false);
        element('panelfive').addEventListener('drop', handleDrop, false);
        element('panelsix').addEventListener('drop', handleDrop, false);
  • 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-15T23:31:01+00:00Added an answer on June 15, 2026 at 11:31 pm

    I make the assumption that preflist is a Backbone Model. Your mistake happens here:

    var data = dataattribute + " " + datavalue;
    preflist.set(data);
    

    The data variable here is a string, but the Backbone model set -function takes a hash of attributes as key-value pairs

    set model.set(attributes, [options])

    Set a hash of attributes (one or many) on the model…

    So you should do it like this:

    // var data = dataattribute + " " + datavalue; REMOVE THIS
    var data = {};
    data[dataattribute] = datavalue;
    preflist.set(data);
    

    EDIT, mu is too short’s comment was better

    According to Backbone.js docs

    You may also pass individual keys and values.

    So this is a better solution, obviously:

    preflist.set(dataattribute, datavalue);
    

    Hope this helps?

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

Sidebar

Related Questions

I am having a design issue, this may be due to the fact that
This may be the wrong place but this is new to me. I did
This may be a simple question but I can;t find the answer anywhere. Here
This may seem a bit crazy, but if you can tell me a better
I know this is a big one. In fact, it may be used for
Although this has been asked before, due to the fact that no satisfactory answer
I will preface this question with the fact that I am extremely new to
This may be a stupid question but I have a code with the following
This may be have a better name than custom tab completion, but here's the
this may sound a newbie question anyway Im new to GCD, I'm creating and

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.