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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T16:06:41+00:00 2026-06-04T16:06:41+00:00

I want to inject an old style, procedurally built string into a DIV element

  • 0

I want to inject an old style, procedurally built string into a DIV element that’s created in a standard ExtJS 4 MVC application, and I’m having a hard time wrapping my head around how I’m supposed to leverage dynamic loading.

So say I have this function by itself in a javascript file called “createHtml.js”:

function fillDiv(strDivName)    {
    document.getElementById(strDivName).innerHTML = "<h1>TEST</h1>";
}

Elsewhere, in my MVC ExtJS 4 app (so in an object referenced within app.js, I have the following:

myPanel = Ext.create('Ext.panel.Panel', {
    title: 'Map',
    html: '<div style="width:100%; height:100%" id="map"></div>'
});

In my index.html page, I include a reference to createHtml.js. In my app.js file, I have something like the following:

( function() {
    Ext.Loader.setConfig({
        enabled : true,
        paths   : {
            MyJive: 'media/js/ext/MyCom/MyJive',
        }
    });
    Ext.onReady( function() {
        var urlparams = document.URL.split('?')[1];
        var param = Ext.urlDecode( urlparams ? urlparams : '' );
        var pcard = Ext.create( 'MyJive.view.MyUI',{
            param1 : param.param1,
            param2: param.param2
        });
        Ext.create( 'Ext.container.Viewport', {
            layout: 'fit',
            items: [pcard]
        });
    });
})();

Now if I attach a listener to a button somewhere on MyUI and have it call fillDiv('map'); I get a Uncaught ReferenceError: fillDiv is not defined error.

If I put fillDiv not in its own file (createHtml.js) but MyUI.js (referenced by pcard, above), I’m golden. So I know it’s not a super-stupid issue like having the div id wrong or some wacky, invalid innerHTML value.

I would have thought the app would know about fillDiv() because fillDiv()’s parent file is in index.html’s javascript includes, but fine, createHtml.js isn’t being dynamically loaded. I’ve got that, I guess.

But how do I tell app.js that my function exists in a file outside of its bounds?

(Now, “IRL”, I’ve got fillDiv creating a complicated piece of html via OpenLayers so that we can display a map identified by param1 and param2 embedded in the ExtJS form, but I’ve gone to this simpler setup to try and figure out what I’m doing wrong.)

EDIT: Added index.html. createHtml.js contains the fillDiv() method. Note that the DIV that takes the map isn’t in the index.html; it’s, again, defined in an ExtJS Panel.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
    <head>
        <title>My Project</title>
        <link rel="stylesheet" type="text/css" 
                href="media/js/ext/ext-4.0/css/ext-all.css" />
        <link rel="stylesheet" type="text/css"
                href="media/js/ext/MyCom/MyJive/css/main.css" />

        <script type="text/javascript" 
                src="media/js/ext/MyCom/MyJive/createHtml.js"></script>
        <script type="text/javascript" 
                src="media/js/ext/MyCom/MyJive/OpenLayers-2.11/OpenLayers.js"></script>
        <script type="text/javascript" 
                src="media/js/ext/ext-4.0/ext-all-debug-w-comments.js"></script>

        <script type="text/javascript"
                src="media/js/ext/MyCom/MyJive/app.js"></script>
    </head>
    <body>
        <div id="divParent"></div>
    </body>
</html>

EDIT: Adding app.js:

( function() {
    Ext.Loader.setConfig({
        enabled : true,
        paths   : {
            MyProj: 'media/js/ext/MyCom/MyProj',
            OpenLayers: 'media/js/ext/MyCom/MapJive/OpenLayers-2.11',
            MyComExt  : 'media/js/ext/MyCom/MyComExt'
        }
    });
    Ext.onReady( function() {
        var urlparams = document.URL.split('?')[1];
        var param = Ext.urlDecode( urlparams ? urlparams : '' );
        var pcard = Ext.create( 'MyProj.view.MyProj',{
            param1: param.p1,
            param2: param.p2
        });
        Ext.create( 'Ext.container.Viewport', {
            layout: 'fit',
            items: [pcard]
        });
    });
})();
  • 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-04T16:06:43+00:00Added an answer on June 4, 2026 at 4:06 pm

    I would leave just a comment, but I don’t have enough points for that.

    You didn’t include a index.html file with imports of your createHtml.js and app.js files. But the first thing I would check is that your createHtml.js import is placed above app.js.

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

Sidebar

Related Questions

I want to inject one additional variable into the context of a view that
I want to inject a connection string into my repository but ideally, I want
I have a service that I want to inject into multiple client classes. I
I'm using Spring 3 and want to inject some dependencies into a class that
I want to inject some Json into the Html page returned by the server?
I'm using Structure map and want to inject instance (constructed by container) into controller's
I want to create a method ( set ) that injects arguments into another
I just want to inject some design patterns into my Java code, but I
I want to inject some HTML into some websites with a Chrome extension, and
I have a WPF UserControl that I'd like to inject dependencies into. What's 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.