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

  • Home
  • SEARCH
  • 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 8485311
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T20:36:27+00:00 2026-06-10T20:36:27+00:00

In my actual project, the users have the option to click a button in

  • 0

In my actual project, the users have the option to click a button in order to enter in an “edit mode” for their websites. After clicking the button, I have to download several JS and CSS files and I was doing it using the following code:

//Start edition mode
(function(){
    $.get('/helpers/edit/v/edit.php',function(data){
        $(data).appendTo('body');
        var css = '/helpers/edit/css/edit.css';
        $.get(css,function(data){
            $('<link/>')
                .attr({
                    'rel':'stylesheet',
                    'href':css
                }).appendTo('head');
            $("body").trigger("editReady");
        });
    });
})();

It works fine but now I need to insert more JS and CSS files and if I just keep nesting jquery get requests the code will become ugly and hard to mantain, which I want to avoid and shows me that this is probably not the best way to accomplish the task.

I also tried to use Yep Nope (which I’m already using in other parts of the project) inside the first get request but it seems not to work (I receive no error messages but it just doesn’t work).

Does anyone have an idea of how to do this in a way that doesn’t get so ugly and, mainly, is easy to mantain (considering that I have to trigger an event when all the JS/CSS are properly included)?

Thanks in advance!

  • 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-10T20:36:28+00:00Added an answer on June 10, 2026 at 8:36 pm

    I had a similar issue loading JSON from multiple sources recently. I modified that code and came up with this. The gist of it is to loop through get requests to your various URL’s and then trigger your “editReady” event when the number of requests completed is equal to the number of URL’s in the data_urls array (i = data_urls.length).

    I originally wrote this in CoffeeScript so it’s possible that I messed up a bracket or something somewhere…

    function() {
      var data_urls = ['/helpers/edit/v/edit.php', '/helpers/edit/css/edit.css'];
      var i = 0;
      var _i, _len;
      for (_i = 0, _len = data_urls.length; _i < _len; _i++) {
        $.get(data_urls[i], function(data) {
          if (data_urls[i].match(/\.php/).length > 0) {
            $(data).appendTo('body');
          } else if (data_urls[i].match(/\.css/).length > 0) {
          $('<link/>')
            .attr({
              'rel':'stylesheet',
              'href':css
            }).appendTo('head');
          }
          i += 1;
          if (i == data_urls.length) {
            $("body").trigger("editReady");
          }
        });
      }
    } 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've put a actual folder inside my app project and i would like to
I only have one actual device to test on, a Nexus One but I've
I have two BigDecimals Actual, and Budgeted. I am dividing Actual by Budgeted to
For the project I'm working on, we have a desktop program that contacts an
I've recently begun a fairly small 2D project using SFML and TinyXML and have
I have multimedia files and its metadata stored in a RDBMS (actually, the actual
I have a form that users fill out, and on the form there are
I have a personal project that's been online for sometime now. I've been keeping
I have a freelance project where I have to build a news articles based
I have an editor that lets users add HTML that is stored in the

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.