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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T12:24:06+00:00 2026-06-10T12:24:06+00:00

This is really getting me frustrated. I’m trying to build a custom JavaScript app

  • 0

This is really getting me frustrated. I’m trying to build a custom JavaScript app with no libraries. This is mainly for me to learn better core JavaScript and JavaScript patterns. I’m trying to implement the MVC structure and I understand the parts separately, but for the life of me I can’t figure out how to connect the views and controllers together. For example if I have this code:

<div>
    <button id="button1">Click Me</button>
    <button id="button2">Click Me</button>
    <button id="button3">Click Me</button>
</div>

How in the world do I write a controller.js file to listen to the clicks of each button and respond. Especially if each button does something totally different from the others. Let’s say button1 simply links to google.com, button2 opens a modal box and button3 updates a database table. So each one is doing something totally separate. What I am trying to avoid is using jQuery to do something like this.

$('#button1').click(function(){
       //go to google.com
});

$('#button2').click(function(){
       //open modal box
});

$('#button3').click(function(){
       //update database
});

This doesn’t seem very efficient, especially when trying to use the MVC structure. Is there a smoother way, even a few different design patterns I can follow to write this is core JavaScript with no libraries? I scoured the net to find articles but everything I find relies heavily on a library.

Any books, tutorials, blog posts or anything of the like that will clearly explain something like this is much much appreciated. Who knows once I get the hang of it maybe I’ll write a book on it for the masses.

Once again the help of the community is always appreciated.

  • 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-10T12:24:07+00:00Added an answer on June 10, 2026 at 12:24 pm

    You are writing an application in Javascript, following the MVC design pattern, and it’s a great idea to understand core javascript, as you will have to adapt existing design patterns on js 🙂

    I would have parsed the DOM recursively at first, retrieving each tag, and then associated them simple click event code that call a click_event generic (and global) function, with the button id as parameter, to have a single entry point that identify the button.

    Then this generic method (event entry point) would have to select and launch the appropriate controller for the action.

    You might also go one step further with 2 parameters: objectId or reference, and event type. This is very similar of what you will find on many basic GUI to fire events.

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

Sidebar

Related Questions

Arghhh! I'm getting so frustrated trying to get my head around this WCF service.
I'm developing a Silverlight 3 app and getting this really weird error when I
Okay...I'm really getting a bit frustrated with this. I know that this post will
This program is really getting on my nerves: I am trying to read a
This one's really getting me down! :( I'm trying to make a nested model
I'm getting really frustrated as I'm trying to get an array to my _Click-Event
Ok, I'm getting really frustrated with Javascript. I have bought the books, found tons
Im getting really frustrated with this error. After i updated to sdk 1.6.6 im
This is really getting to me now.I have a form that loads when the
Sorry if this is a really basic question but it's been really getting to

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.