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 8368867
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T13:29:35+00:00 2026-06-09T13:29:35+00:00

I am creating an instance of blockView in view and passing model as an

  • 0

I am creating an instance of blockView in view and passing model as an parameter. But when I run it it gives me error “TypeError: can’t convert undefined to object”. I tried to trace this error but i am not able to get. Anyone plz. Plz find code below

 var DCSSPACE = DCSSPACE || {};
    $(document).ready(function(){
        WorkSpace = new draw2d.Workflow( "canvasdiv" );
        collection = new DCSSPACE.collection.collection();
        view = new DCSSPACE.view.view({WorkSpace : WorkSpace, collection : collection});


    });

    DCSSPACE.view = function(){
        var uniqueid = 1, blockCounter = 0;
    var view = Backbone.View.extend({
        el : $("#canvasdiv"),
        views : {},

        initialize : function() {
            console.log("View");

            this.collection.bind("add", function(m, temp, data){
                console.log(data.evt);
//Here i am getting error "TypeError: can't convert undefined to object"                
this.views[m.cid] = new blockView({data : data, model : m, id : "view_" + m.cid});
                },this);

            this.collection.bind("remove", function(m){
                this.views[m.cid].remove();
                delete this.views[m.cid];
            }, this);
            this.render(WorkSpace);
        },
        render : function(WorkSpace) {
            $("#sidediv").accordion();
            this.disableSelection(document.body);
            var menu = new draw2d.FlowMenu(WorkSpace);
            WorkSpace.addSelectionListener(menu);
            var toolwindow = new draw2d.Toolbox();
            WorkSpace.setToolWindow(toolwindow);
            toolwindow.setPosition(0,0);
            $(".btn").draggable({
                helper : "clone",
                stop : function(event, ui) {
                    var data = {
                        id : this.id,
                        evt : event.originalEvent,
                    };
                    if(event.originalEvent.pageX >= 220) {
                        var m = new DCSSPACE.model.FunctionBlockModel();
                        collection.add(m, data);
                    }
                }
            });

            return this;
        },
        /* Function for deselect body contents */
        disableSelection : function(target) {
            if( typeof target.onselectstart != "undefined")//IE
                target.onselectstart = function() {
                    return false;
                }
            else if( typeof target.style.MozUserSelect != "undefined")//Firefox
                target.style.MozUserSelect = "none"
            else//All other
                target.onmousedown = function() {
                    return false
                }
            target.style.cursor = "default"
        }
    });

    var blockView = Backbone.View.extend({
            initialize : function(formalObj){
                console.log("block view");
                $("#canvasdiv").mousemove(this, this.mousemove).mouseup(this, this.mouseup);
                this.model.set({id : formalObj.data.id});
                console.log(JSON.stringify(collection));
                var nodeObj = this.block(formalObj.data);

            },

            block : function(data){
                var Obj = new draw2d.node();
                var self = this;
                Obj.onDoubleClick = function(){
                    self.informationBlock(Obj.getnodeName());
                };
                    Obj.setTitle(collection.get(data.id).get("id")+" "+ (uniqueid++));
                    Obj.setFooter("#" + (++blockCounter));
                    WorkSpace.addFigure(Obj, data.evt.pageX - 205, data.evt.pageY);

    });
    return{
        view : view,
        blockView : blockView
    }

    }();
  • 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-09T13:29:37+00:00Added an answer on June 9, 2026 at 1:29 pm

    Try to instantiate your View like this:

    view = new DCSSPACE.view.view({model : WorkSpace, collection : collection});
    

    And in your View implementation replace any WorkSpace reference for this.model.

    Personal note: I think you should work in try to clean up and organize your code 🙂
    Personal note2: when you receive a JS error, usually there is more information that could be helpful to find the issue, like, for example, the exactly code line.

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

Sidebar

Related Questions

I'm trying to use urbanairship push notification. But while creating instance of UAirship, it
After creating a instance of a class, can we invoke the constructor explicitly? For
When using Objective-C properties can you stop creating instance variables altogether or do explicit
I'm creating an instance of a class using the TRttiMethod.Invoke function , but when
I have problem creating new instance of excel 2007 using VBA (from Access 2002).
I´m dynamically creating an instance of a class with reflection and this works fine,
I'm having trouble creating an instance of a class using Python's re module. Here's
Having a bit of a problem creating an instance of an object. Bear in
What's the correct way to prevent invoking (creating an instance of) a C type
When creating a new instance of a MyClass as an argument to a function

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.