Help with automating javascript, modal popup, wiring up buttons

Posted on 2013-10-15
Medium Priority
Last Modified: 2013-10-15
I have a main page that has a list of records.  On the page are Add, Edit and View buttons which when clicked, invoke javascript and display modal popups that allow for adding new record, editing an existing record, or viewing an existing record.  The Add and Edit modal popups have Save and Cancel buttons.  The View popup just has a Close button.  For the Save and Cancel buttons I also have javascript that passes back a value via window.returnValue.

I do this for each app/set pf pages I create.  I want to somehow try to automate this process.  I have to copy and paste all the javascript, wiring up the buttons, etc.   The only thing that is different each time is the name of all the pages, i.e., the main page, the add page, the edit page and the view page, and these names in the corresponding javascript.

Any thoughts on how to automate this?
Question by:HLRosenberger
  • 2
LVL 75

Accepted Solution

käµfm³d   👽 earned 2000 total points
ID: 39573584
You might look into T4 templates. You can write up a template script that you can use a built-in transformation tool to generate code items (or really any text file). This is actually how Entity Framework generates its entity classes once you set up the connection to the database.

Once you have created your script, you could then package it up as an "Add New Item" entry. To do that, you would need to export it. You would use the File->Export Template menu option to do this. Once you export it, you will have a self-contained unit that you could then distribute among your peers.

Author Comment

ID: 39573768
ok, I'm looking at the write-up.   So, it will generate any text?   can I somehow pass it the names of the forms and buttons that I have to create and wire-up?

Author Closing Comment

ID: 39574665

Featured Post

Easily Design & Build Your Next Website

Squarespace’s all-in-one platform gives you everything you need to express yourself creatively online, whether it is with a domain, website, or online store. Get started with your free trial today, and when ready, take 10% off your first purchase with offer code 'EXPERTS'.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Before you approach an Ionic Mobile App development company for developing mobile apps using the ionic framework, you must know why you should choose the framework. Let's try to understand that through this article.
This article describes and provides a custom-made tool I wrote to give businesses a means of identifying commercial music content, without having to expend too much effort. Business recordings are easily identified from possibly illegal music files …
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

619 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question