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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T07:14:57+00:00 2026-05-24T07:14:57+00:00

I have about 30 different modules for my CMS and the following is code

  • 0

I have about 30 different modules for my CMS and the following is code is included on every module’s javascript except for a just a few changes and didn’t know if there is an easier way or something more I can do to eliminate having to copy the same code over and over just in case I have to go back and change something I can only do it once. But the parts that are different on the pages is anything that says the word templates is different on each page because it represents the modular name. I didn’t know if I could change stuff to be like itemID and whatever else.

$('.ask').jConfirmAction( {
    question : "Are you sure you want to delete the selected row?", 
    yesAnswer : "Yes", 
    cancelAnswer : "No", 
    onYes: function(evt) { 
      templates(evt.target); 
    }
});

$('.ask2').jConfirmAction( {
    question : "Are you sure you want to delete all selected rows?",
    questionClass: "question2", 
    onYes: function(evt){
        templatesArray(evt.target); 
    }
});

function templates(whatsThis) {
    var templateID = $(whatsThis).parents('td').find('img').attr('id');
    var dataString = 'templateID=' + templateID + '&deleteTemplate=True'; 

    var iRow = oTable.fnGetPosition( $(whatsThis).parents('tr').get(0));

    $.ajax({ 
        type: "POST", 
        url: "processes/templates.php", 
        data: dataString,
        success: function(data) {
            if (data.errorsExist) {
            } else {
                oTable.fnDeleteRow(iRow);     // remove the row from the table
                if(oTable.fnSettings().fnRecordsTotal() == 0) {
                    $('.bt_red').remove();
                    $('.bt_blue').remove();
                }
                if(oTable.fnSettings().fnRecordsTotal() <= 10) {
                    $('.bt_blue').remove();
                }
            } 
        }
    });
}


function templatesArray(whatsThis) {
    var myNewArray = new Array(); 
    var aRow = new Array();

    $('input:checkbox[name="templates"]:checked').each(function(i) { 
        myNewArray.push($(this).val());
        aRow.push($(this).closest('tr')[0]);
    }); 
    var dataString = 'templatesArray=' + myNewArray + '&deleteTemplatesArray=True'; 
    $.ajax({ 
        type: "POST", 
        url: "processes/templates.php", 
        data: dataString,
        success: function(data) {
            if (data.errorsExist) {
            } else {
                $(whatsThis).parents("tr").eq(0).hide(); 
                for (i in aRow)  // loop over the array of row indexes
                  oTable.fnDeleteRow(aRow[i]);
                if(oTable.fnSettings().fnRecordsTotal() == 0) {
                    $('.bt_red').remove();
                    $('.bt_blue').remove();
                }
                if(oTable.fnSettings().fnRecordsTotal() <= 10) {
                    $('.bt_blue').remove();
                }                      
            } 
        }
    });

}
  • 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-05-24T07:14:58+00:00Added an answer on May 24, 2026 at 7:14 am

    The code is doing different things and accessing different objects onYes. I don’t think it can be combined. Maybe some other functions that are simialr can be but not the ones posted.

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

Sidebar

Related Questions

Do I have to put every file in a different folder? like: about-us/about-us.php profile/profile.php
At my house I have about 10 computers all different processors and speeds (all
Recently I have read a lot about different NoSQL databases and how they are
I have a scene in my WPF project with about 2000 different user controls:
I have implemented an IHttpAsyncHandler. I am making about 5 different AJAX calls from
I have a bit of a situation. I've consumed about fourty-eleven different tutorials/books/videos on
I'm thinking about how to do this, but I have several different shapes of
Background: I work in a suite of ASP.NET applications that have several different modules.
So I have an application that has several modules (think of modules as different
Given the following modules: adonetlib.psml param($ModelModule) $dbmodel=import-module $ModelModule -AsCustomObject function new-ADOnetconnection{ return $dbmodel.newconnection() }

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.