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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T11:19:20+00:00 2026-06-14T11:19:20+00:00

I am trying to create a reusable Header object with a right button. I’m

  • 0

I am trying to create a reusable Header object with a right button. I’m having problems on my callback method on the button click. It’s never called.

My object:

myHeader:function(params)   
{       
    opt = {
        title: "Title",  //header tittle
        fs: PrecApp.DEFAULT_HEADER_FONTSIZE, //font size
        ignoreStack :true, //ignore stack
        height: "70", //header height
        rightButton: {
            show :false, //show right button
            background: "none", //background for right button
            text: "Button", //text for right button
            width: "auto",
            height:"auto",              
            color:"black",
            fontize:1,
            extraCss: null,
            onClick:function(){}
        }
    }
for (i in params) opt[i] = params[i];

    if (opt.rightButton.show){
        var right = $("#header .right");            
        right.click(opt.rightButton.onClick);           

    }       
}

And in my html :

function updateLayout(){
                PrecAppComponents.myHeader({
                    title:"My Title",
                    fs:1.5,
                    height:50,
                    rightButton:{
                        show:true,
                        background:"#ffff00",
                        text:"Right",
                        width:70,
                        height:30,
                        fontsize:1.1,
                        extraCss: {"float":"left", "font-size":"0.5em"},
                        onClick: PrecAppComponents.toggleDarkOverlay(true)

                    }
}

Everything else is working fine. If i replace

right.click(opt.rightButton.onClick);       

with

 right.click(function(
  console.log("clicked")
));     

It works fine. What am I doing wrong?

  • 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-14T11:19:22+00:00Added an answer on June 14, 2026 at 11:19 am

    It looks like your onClick option is calling a function. Unless that call is returning another function, this won’t work:

    onClick: PrecAppComponents.toggleDarkOverlay(true)
    

    You’d have to change it to something like:

    onClick: function() {
      PrecAppComponents.toggleDarkOverlay(true);
    }
    
    // or with bind, perhaps
    
    onClick: PrecAppComponents.toggleDarkOverlay.bind(PrecAppComponents, true);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to create a reusable javascript object (I want to use new).
I'm trying to create a reusable component to display some photo collection. The basic
I am trying to create some reusable components in Silverlight2 . The difficulty comes
I am trying to create a Validation in a reusable fashion. Purpose: Make the
I'm trying to create a view that only houses reusable HTML blocks that can
I am trying create a delegate representation of constructor by emitting a Dynamic Method,
I've been having problems created modular reusable components in my Zend Framework app. In
I need to create a custom, reusable view component. I've been trying to look
I am trying to create a reusable function that can open a single instance
I'm trying to create a reusable UserControl in WPF that has a Label 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.