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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T14:31:40+00:00 2026-06-05T14:31:40+00:00

I am working on a class to create a fairly complex custom element. I

  • 0

I am working on a class to create a fairly complex custom element. I want to be able to define element attributes (mainly CSS) as I am creating the elements. I came up with the below function to quickly set attrs for me given an input array:

// Sample array structure of apply_settings
//var _button_div =   {
//    syle    :   {
//        position:   'absolute',
//        padding :   '2px',
//        right   :   0,
//        top     :   0
//    }
//};
function __apply_settings(__el,apply_settings){
    try{
        for(settingKey in apply_settings){
            __setting = apply_settings[settingKey];
            if(typeof(__setting)=='string'){
                __el[settingKey] = __setting;
            }else{
                for(i in __setting){
                    __el[settingKey][i] = apply_settings[settingKey][i];
                } 
            }
        }
    }catch(ex){
        alert(ex + "   " + __el);
    }
}

The function works fine except here:

function __draw_top(){
    var containerDiv = document.createElement('div');
    var buttonDiv = document.createElement('div');
    __apply_settings(containerDiv,this.settings.top_bar);
    if(global_settings.show_x)
        buttonDiv.appendChild(__create_img(global_settings.images.close));
    containerDiv.appendChild(buttonDiv);
    __apply_settings(buttonDiv,this.settings.button_div);
    return containerDiv;
}

The specific section that is failing is __apply_settings(buttonDiv,this.settings.button_div); with the error “Cannot set property ‘position’ of undefined”. So naturally, I am assuming that buttonDiv is undefined.. I put alert(ex + " " + __el); in __apply_settings() to verify what I was working with. Surprisingly enough, the element is a div. Is there any reason why this function would be working for containerDiv and not buttonDiv? Any help would be greatly appreciated 🙂

{EDIT}
http://jsfiddle.net/Us8Zw/2/

  • 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-05T14:31:41+00:00Added an answer on June 5, 2026 at 2:31 pm

    That’s because you have a typo here:

    var _button_div =   {
        syle    :   { //<--- here
            position:   'absolute',
            padding :   '2px',
            right   :   0,
            top     :   0
        }
    };
    

    If you correct it to style, it works fine; http://jsfiddle.net/Us8Zw/3/

    I’d also advise you to try and follow a well known style guide (rather than seemingly making up your own); your code is quite hard to read at the moment. One I recommend is the Crockford Style Guide.

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

Sidebar

Related Questions

Now , I am working with Visual Studio 2008. I want to Create Class
Does anyone have a working class or function to create the hashed email that
UPDATE: This is the working example. First we create a class to hold weekday,
In working with Linq to Sql I create a seperate class to ferry data
I'm currently working on a class to create and read out packets send through
I have a fairly complex multi-threaded Windows service working, but I can't figure out
I'm working on a C# project that uses System.Data.OleDb.OleDbCommand class to create and alter
Can anybody say me, why that isn't working: class A attr_accessor :b end a
using System; using System.IO; using System.Net; using System.Text.RegularExpressions; namespace Working { class Program4 {
I have a working wrapper class for Dallmeier camera devices, It contains a callback

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.