Function undefined - External JS












-1














I want to create an organized js lib. for my application.



I am moving to external js files.



However, when I try to call my function from my page it shows as undefined.



What am I missing here? Why am I getting undefined error yet am able to log to console from the undefined function?



My external js look something like:



var fmp = (function () {

var _fmp = {};

////////////////////
//layout
////////////////////
_fmp.layout = {
setLayoutHeight : function (dom, height) {
console.log(dom, height);
}
};



////////////////////
//templates
////////////////////
_fmp.templates = { };

//Kendo Grid Client Template for Customer Results/List in Card View format
_fmp.templates.CustomerListCardView = function (data) {
return '<div class="pure-g">' +
'<div class="pure-u-8-24"></div>' +
'<div class="pure-u-16-24">' + data.CustomerId + '</div>' +
'</div >';
};


////////////////////
//page specific
////////////////////
_fmp.page = {};

//Map page
_fmp.page.Map = {};
_fmp.page.Map.InitMap = function (dom,height) {
var map;
map = new google.maps.Map(document.getElementById(dom), {
center: { lat: -34.397, lng: 150.644 },
zoom: 8
});
console.log(map);
$("#"+dom).height(height);
};

return _fmp;
})();


This outputs in console



#app-splitter,section.panel 957.432 

ReferenceError: setLayoutHeight is not defined


I call this from html as:



<script>
$(function () {
//named functions only

fmp.layout.setLayoutHeight("#app-splitter,section.panel",957.432);
});
</script>


Document Layout looks like:



@using FMPWeb.Classes;
@using Microsoft.AspNetCore.Razor.TagHelpers;
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>@ViewData["Title"] - TelerikAspNetCoreApp1</title>
<environment names="dev,local,qa">
<link rel="stylesheet" href="~/css/site.css" />
<link rel="stylesheet" href="~/css/puregrids.css" />
</environment>
<environment names="test,prod">
<link rel="stylesheet" href="~/css/site.min.css" asp-append-version="true" />
<link rel="stylesheet" href="~/css/puregrids.css" />
</environment>
<script src="https://kendo.cdn.telerik.com/2018.3.1017/js/jquery.min.js"></script>
</head>
<body>
@await Component.InvokeAsync("Header", (int)UiConstants.ComponentHeader.HeaderAuthenticated)
<application>
@RenderBody()
</application>
@await Component.InvokeAsync("Window", (int)UiConstants.ComponentWindow.WindowMasterNav)
<link href="https://kendo.cdn.telerik.com/2018.3.1017/styles/kendo.common-material.min.css" rel="stylesheet" type="text/css" />
@*<link href="https://kendo.cdn.telerik.com/2018.3.1017/styles/kendo.mobile.all.min.css" rel="stylesheet" type="text/css" />*@
<link href="https://kendo.cdn.telerik.com/2018.3.1017/styles/kendo.material.min.css" rel="stylesheet" type="text/css" />
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
@*<script src="https://kendo.cdn.telerik.com/2018.3.1017/js/jszip.min.js"></script>*@
<script src="https://kendo.cdn.telerik.com/2018.3.1017/js/kendo.all.min.js"></script>
<script src="https://kendo.cdn.telerik.com/2018.3.1017/js/kendo.aspnetmvc.min.js"></script>




    @RenderSection("scripts", required: true)
@Html.Kendo().DeferredScripts()

</body>
</html>









share|improve this question




















  • 1




    Well the code as posted gets a syntax error.
    – Pointy
    Nov 20 at 15:34










  • Oops, typo. Revised.
    – Mark
    Nov 20 at 15:36






  • 1




    Wouldn't wrapping it in an IIFE mean fmp is undefined?
    – George
    Nov 20 at 15:36










  • Sorry, that's another typo. I should have just copied and pasted. Please check agin.
    – Mark
    Nov 20 at 15:39








  • 1




    fmp.js is the very last script included on the page. As such that variable will not be defined until it is included
    – Taplar
    Nov 20 at 15:51
















-1














I want to create an organized js lib. for my application.



I am moving to external js files.



However, when I try to call my function from my page it shows as undefined.



What am I missing here? Why am I getting undefined error yet am able to log to console from the undefined function?



My external js look something like:



var fmp = (function () {

var _fmp = {};

////////////////////
//layout
////////////////////
_fmp.layout = {
setLayoutHeight : function (dom, height) {
console.log(dom, height);
}
};



////////////////////
//templates
////////////////////
_fmp.templates = { };

//Kendo Grid Client Template for Customer Results/List in Card View format
_fmp.templates.CustomerListCardView = function (data) {
return '<div class="pure-g">' +
'<div class="pure-u-8-24"></div>' +
'<div class="pure-u-16-24">' + data.CustomerId + '</div>' +
'</div >';
};


////////////////////
//page specific
////////////////////
_fmp.page = {};

//Map page
_fmp.page.Map = {};
_fmp.page.Map.InitMap = function (dom,height) {
var map;
map = new google.maps.Map(document.getElementById(dom), {
center: { lat: -34.397, lng: 150.644 },
zoom: 8
});
console.log(map);
$("#"+dom).height(height);
};

return _fmp;
})();


This outputs in console



#app-splitter,section.panel 957.432 

ReferenceError: setLayoutHeight is not defined


I call this from html as:



<script>
$(function () {
//named functions only

fmp.layout.setLayoutHeight("#app-splitter,section.panel",957.432);
});
</script>


Document Layout looks like:



@using FMPWeb.Classes;
@using Microsoft.AspNetCore.Razor.TagHelpers;
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>@ViewData["Title"] - TelerikAspNetCoreApp1</title>
<environment names="dev,local,qa">
<link rel="stylesheet" href="~/css/site.css" />
<link rel="stylesheet" href="~/css/puregrids.css" />
</environment>
<environment names="test,prod">
<link rel="stylesheet" href="~/css/site.min.css" asp-append-version="true" />
<link rel="stylesheet" href="~/css/puregrids.css" />
</environment>
<script src="https://kendo.cdn.telerik.com/2018.3.1017/js/jquery.min.js"></script>
</head>
<body>
@await Component.InvokeAsync("Header", (int)UiConstants.ComponentHeader.HeaderAuthenticated)
<application>
@RenderBody()
</application>
@await Component.InvokeAsync("Window", (int)UiConstants.ComponentWindow.WindowMasterNav)
<link href="https://kendo.cdn.telerik.com/2018.3.1017/styles/kendo.common-material.min.css" rel="stylesheet" type="text/css" />
@*<link href="https://kendo.cdn.telerik.com/2018.3.1017/styles/kendo.mobile.all.min.css" rel="stylesheet" type="text/css" />*@
<link href="https://kendo.cdn.telerik.com/2018.3.1017/styles/kendo.material.min.css" rel="stylesheet" type="text/css" />
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
@*<script src="https://kendo.cdn.telerik.com/2018.3.1017/js/jszip.min.js"></script>*@
<script src="https://kendo.cdn.telerik.com/2018.3.1017/js/kendo.all.min.js"></script>
<script src="https://kendo.cdn.telerik.com/2018.3.1017/js/kendo.aspnetmvc.min.js"></script>




    @RenderSection("scripts", required: true)
@Html.Kendo().DeferredScripts()

</body>
</html>









share|improve this question




















  • 1




    Well the code as posted gets a syntax error.
    – Pointy
    Nov 20 at 15:34










  • Oops, typo. Revised.
    – Mark
    Nov 20 at 15:36






  • 1




    Wouldn't wrapping it in an IIFE mean fmp is undefined?
    – George
    Nov 20 at 15:36










  • Sorry, that's another typo. I should have just copied and pasted. Please check agin.
    – Mark
    Nov 20 at 15:39








  • 1




    fmp.js is the very last script included on the page. As such that variable will not be defined until it is included
    – Taplar
    Nov 20 at 15:51














-1












-1








-1


1





I want to create an organized js lib. for my application.



I am moving to external js files.



However, when I try to call my function from my page it shows as undefined.



What am I missing here? Why am I getting undefined error yet am able to log to console from the undefined function?



My external js look something like:



var fmp = (function () {

var _fmp = {};

////////////////////
//layout
////////////////////
_fmp.layout = {
setLayoutHeight : function (dom, height) {
console.log(dom, height);
}
};



////////////////////
//templates
////////////////////
_fmp.templates = { };

//Kendo Grid Client Template for Customer Results/List in Card View format
_fmp.templates.CustomerListCardView = function (data) {
return '<div class="pure-g">' +
'<div class="pure-u-8-24"></div>' +
'<div class="pure-u-16-24">' + data.CustomerId + '</div>' +
'</div >';
};


////////////////////
//page specific
////////////////////
_fmp.page = {};

//Map page
_fmp.page.Map = {};
_fmp.page.Map.InitMap = function (dom,height) {
var map;
map = new google.maps.Map(document.getElementById(dom), {
center: { lat: -34.397, lng: 150.644 },
zoom: 8
});
console.log(map);
$("#"+dom).height(height);
};

return _fmp;
})();


This outputs in console



#app-splitter,section.panel 957.432 

ReferenceError: setLayoutHeight is not defined


I call this from html as:



<script>
$(function () {
//named functions only

fmp.layout.setLayoutHeight("#app-splitter,section.panel",957.432);
});
</script>


Document Layout looks like:



@using FMPWeb.Classes;
@using Microsoft.AspNetCore.Razor.TagHelpers;
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>@ViewData["Title"] - TelerikAspNetCoreApp1</title>
<environment names="dev,local,qa">
<link rel="stylesheet" href="~/css/site.css" />
<link rel="stylesheet" href="~/css/puregrids.css" />
</environment>
<environment names="test,prod">
<link rel="stylesheet" href="~/css/site.min.css" asp-append-version="true" />
<link rel="stylesheet" href="~/css/puregrids.css" />
</environment>
<script src="https://kendo.cdn.telerik.com/2018.3.1017/js/jquery.min.js"></script>
</head>
<body>
@await Component.InvokeAsync("Header", (int)UiConstants.ComponentHeader.HeaderAuthenticated)
<application>
@RenderBody()
</application>
@await Component.InvokeAsync("Window", (int)UiConstants.ComponentWindow.WindowMasterNav)
<link href="https://kendo.cdn.telerik.com/2018.3.1017/styles/kendo.common-material.min.css" rel="stylesheet" type="text/css" />
@*<link href="https://kendo.cdn.telerik.com/2018.3.1017/styles/kendo.mobile.all.min.css" rel="stylesheet" type="text/css" />*@
<link href="https://kendo.cdn.telerik.com/2018.3.1017/styles/kendo.material.min.css" rel="stylesheet" type="text/css" />
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
@*<script src="https://kendo.cdn.telerik.com/2018.3.1017/js/jszip.min.js"></script>*@
<script src="https://kendo.cdn.telerik.com/2018.3.1017/js/kendo.all.min.js"></script>
<script src="https://kendo.cdn.telerik.com/2018.3.1017/js/kendo.aspnetmvc.min.js"></script>




    @RenderSection("scripts", required: true)
@Html.Kendo().DeferredScripts()

</body>
</html>









share|improve this question















I want to create an organized js lib. for my application.



I am moving to external js files.



However, when I try to call my function from my page it shows as undefined.



What am I missing here? Why am I getting undefined error yet am able to log to console from the undefined function?



My external js look something like:



var fmp = (function () {

var _fmp = {};

////////////////////
//layout
////////////////////
_fmp.layout = {
setLayoutHeight : function (dom, height) {
console.log(dom, height);
}
};



////////////////////
//templates
////////////////////
_fmp.templates = { };

//Kendo Grid Client Template for Customer Results/List in Card View format
_fmp.templates.CustomerListCardView = function (data) {
return '<div class="pure-g">' +
'<div class="pure-u-8-24"></div>' +
'<div class="pure-u-16-24">' + data.CustomerId + '</div>' +
'</div >';
};


////////////////////
//page specific
////////////////////
_fmp.page = {};

//Map page
_fmp.page.Map = {};
_fmp.page.Map.InitMap = function (dom,height) {
var map;
map = new google.maps.Map(document.getElementById(dom), {
center: { lat: -34.397, lng: 150.644 },
zoom: 8
});
console.log(map);
$("#"+dom).height(height);
};

return _fmp;
})();


This outputs in console



#app-splitter,section.panel 957.432 

ReferenceError: setLayoutHeight is not defined


I call this from html as:



<script>
$(function () {
//named functions only

fmp.layout.setLayoutHeight("#app-splitter,section.panel",957.432);
});
</script>


Document Layout looks like:



@using FMPWeb.Classes;
@using Microsoft.AspNetCore.Razor.TagHelpers;
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>@ViewData["Title"] - TelerikAspNetCoreApp1</title>
<environment names="dev,local,qa">
<link rel="stylesheet" href="~/css/site.css" />
<link rel="stylesheet" href="~/css/puregrids.css" />
</environment>
<environment names="test,prod">
<link rel="stylesheet" href="~/css/site.min.css" asp-append-version="true" />
<link rel="stylesheet" href="~/css/puregrids.css" />
</environment>
<script src="https://kendo.cdn.telerik.com/2018.3.1017/js/jquery.min.js"></script>
</head>
<body>
@await Component.InvokeAsync("Header", (int)UiConstants.ComponentHeader.HeaderAuthenticated)
<application>
@RenderBody()
</application>
@await Component.InvokeAsync("Window", (int)UiConstants.ComponentWindow.WindowMasterNav)
<link href="https://kendo.cdn.telerik.com/2018.3.1017/styles/kendo.common-material.min.css" rel="stylesheet" type="text/css" />
@*<link href="https://kendo.cdn.telerik.com/2018.3.1017/styles/kendo.mobile.all.min.css" rel="stylesheet" type="text/css" />*@
<link href="https://kendo.cdn.telerik.com/2018.3.1017/styles/kendo.material.min.css" rel="stylesheet" type="text/css" />
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
@*<script src="https://kendo.cdn.telerik.com/2018.3.1017/js/jszip.min.js"></script>*@
<script src="https://kendo.cdn.telerik.com/2018.3.1017/js/kendo.all.min.js"></script>
<script src="https://kendo.cdn.telerik.com/2018.3.1017/js/kendo.aspnetmvc.min.js"></script>




    @RenderSection("scripts", required: true)
@Html.Kendo().DeferredScripts()

</body>
</html>






javascript jquery scope






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 20 at 16:01

























asked Nov 20 at 15:33









Mark

2,99663070




2,99663070








  • 1




    Well the code as posted gets a syntax error.
    – Pointy
    Nov 20 at 15:34










  • Oops, typo. Revised.
    – Mark
    Nov 20 at 15:36






  • 1




    Wouldn't wrapping it in an IIFE mean fmp is undefined?
    – George
    Nov 20 at 15:36










  • Sorry, that's another typo. I should have just copied and pasted. Please check agin.
    – Mark
    Nov 20 at 15:39








  • 1




    fmp.js is the very last script included on the page. As such that variable will not be defined until it is included
    – Taplar
    Nov 20 at 15:51














  • 1




    Well the code as posted gets a syntax error.
    – Pointy
    Nov 20 at 15:34










  • Oops, typo. Revised.
    – Mark
    Nov 20 at 15:36






  • 1




    Wouldn't wrapping it in an IIFE mean fmp is undefined?
    – George
    Nov 20 at 15:36










  • Sorry, that's another typo. I should have just copied and pasted. Please check agin.
    – Mark
    Nov 20 at 15:39








  • 1




    fmp.js is the very last script included on the page. As such that variable will not be defined until it is included
    – Taplar
    Nov 20 at 15:51








1




1




Well the code as posted gets a syntax error.
– Pointy
Nov 20 at 15:34




Well the code as posted gets a syntax error.
– Pointy
Nov 20 at 15:34












Oops, typo. Revised.
– Mark
Nov 20 at 15:36




Oops, typo. Revised.
– Mark
Nov 20 at 15:36




1




1




Wouldn't wrapping it in an IIFE mean fmp is undefined?
– George
Nov 20 at 15:36




Wouldn't wrapping it in an IIFE mean fmp is undefined?
– George
Nov 20 at 15:36












Sorry, that's another typo. I should have just copied and pasted. Please check agin.
– Mark
Nov 20 at 15:39






Sorry, that's another typo. I should have just copied and pasted. Please check agin.
– Mark
Nov 20 at 15:39






1




1




fmp.js is the very last script included on the page. As such that variable will not be defined until it is included
– Taplar
Nov 20 at 15:51




fmp.js is the very last script included on the page. As such that variable will not be defined until it is included
– Taplar
Nov 20 at 15:51












1 Answer
1






active

oldest

votes


















2














_fmp will only exist within the scope of your anonymous function. As it stands, fmp doesn't actually return anything, so when you define fmp here, you're just running a function that creates a local-scope variable, sets its layout property, and then... does nothing with it. It will likely just be garbage collected away. If you want access to _fmp, you must return it from that function once you've defined all its properties.






share|improve this answer





















  • Please see comments. That was a copie/paste typo. I do return _fmp.
    – Mark
    Nov 20 at 15:41










  • Assuming you're returning it as you say, and that you're including your external file before trying to use it, I can see nothing wrong. Can you show use the HTML of your page?
    – IceMetalPunk
    Nov 20 at 15:43










  • I've updated the question to show the html layout and inclusion of script files.
    – Mark
    Nov 20 at 15:45










  • I don't know much about how ASP.net does its templates, but I do notice you're including fmp.js all the way at the bottom of your page. That means it'll load last, after everything else, so I'm guessing you're probably trying to access fmp before it's even been loaded.
    – IceMetalPunk
    Nov 20 at 15:53






  • 1




    So when you log fmp.layout, you get that, but if you try to call fmp.layout.setLayoutHeight() in the same place, it says it's undefined? That doesn't make a lot of sense...
    – IceMetalPunk
    Nov 20 at 16:08











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53396402%2ffunction-undefined-external-js%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









2














_fmp will only exist within the scope of your anonymous function. As it stands, fmp doesn't actually return anything, so when you define fmp here, you're just running a function that creates a local-scope variable, sets its layout property, and then... does nothing with it. It will likely just be garbage collected away. If you want access to _fmp, you must return it from that function once you've defined all its properties.






share|improve this answer





















  • Please see comments. That was a copie/paste typo. I do return _fmp.
    – Mark
    Nov 20 at 15:41










  • Assuming you're returning it as you say, and that you're including your external file before trying to use it, I can see nothing wrong. Can you show use the HTML of your page?
    – IceMetalPunk
    Nov 20 at 15:43










  • I've updated the question to show the html layout and inclusion of script files.
    – Mark
    Nov 20 at 15:45










  • I don't know much about how ASP.net does its templates, but I do notice you're including fmp.js all the way at the bottom of your page. That means it'll load last, after everything else, so I'm guessing you're probably trying to access fmp before it's even been loaded.
    – IceMetalPunk
    Nov 20 at 15:53






  • 1




    So when you log fmp.layout, you get that, but if you try to call fmp.layout.setLayoutHeight() in the same place, it says it's undefined? That doesn't make a lot of sense...
    – IceMetalPunk
    Nov 20 at 16:08
















2














_fmp will only exist within the scope of your anonymous function. As it stands, fmp doesn't actually return anything, so when you define fmp here, you're just running a function that creates a local-scope variable, sets its layout property, and then... does nothing with it. It will likely just be garbage collected away. If you want access to _fmp, you must return it from that function once you've defined all its properties.






share|improve this answer





















  • Please see comments. That was a copie/paste typo. I do return _fmp.
    – Mark
    Nov 20 at 15:41










  • Assuming you're returning it as you say, and that you're including your external file before trying to use it, I can see nothing wrong. Can you show use the HTML of your page?
    – IceMetalPunk
    Nov 20 at 15:43










  • I've updated the question to show the html layout and inclusion of script files.
    – Mark
    Nov 20 at 15:45










  • I don't know much about how ASP.net does its templates, but I do notice you're including fmp.js all the way at the bottom of your page. That means it'll load last, after everything else, so I'm guessing you're probably trying to access fmp before it's even been loaded.
    – IceMetalPunk
    Nov 20 at 15:53






  • 1




    So when you log fmp.layout, you get that, but if you try to call fmp.layout.setLayoutHeight() in the same place, it says it's undefined? That doesn't make a lot of sense...
    – IceMetalPunk
    Nov 20 at 16:08














2












2








2






_fmp will only exist within the scope of your anonymous function. As it stands, fmp doesn't actually return anything, so when you define fmp here, you're just running a function that creates a local-scope variable, sets its layout property, and then... does nothing with it. It will likely just be garbage collected away. If you want access to _fmp, you must return it from that function once you've defined all its properties.






share|improve this answer












_fmp will only exist within the scope of your anonymous function. As it stands, fmp doesn't actually return anything, so when you define fmp here, you're just running a function that creates a local-scope variable, sets its layout property, and then... does nothing with it. It will likely just be garbage collected away. If you want access to _fmp, you must return it from that function once you've defined all its properties.







share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 20 at 15:37









IceMetalPunk

477414




477414












  • Please see comments. That was a copie/paste typo. I do return _fmp.
    – Mark
    Nov 20 at 15:41










  • Assuming you're returning it as you say, and that you're including your external file before trying to use it, I can see nothing wrong. Can you show use the HTML of your page?
    – IceMetalPunk
    Nov 20 at 15:43










  • I've updated the question to show the html layout and inclusion of script files.
    – Mark
    Nov 20 at 15:45










  • I don't know much about how ASP.net does its templates, but I do notice you're including fmp.js all the way at the bottom of your page. That means it'll load last, after everything else, so I'm guessing you're probably trying to access fmp before it's even been loaded.
    – IceMetalPunk
    Nov 20 at 15:53






  • 1




    So when you log fmp.layout, you get that, but if you try to call fmp.layout.setLayoutHeight() in the same place, it says it's undefined? That doesn't make a lot of sense...
    – IceMetalPunk
    Nov 20 at 16:08


















  • Please see comments. That was a copie/paste typo. I do return _fmp.
    – Mark
    Nov 20 at 15:41










  • Assuming you're returning it as you say, and that you're including your external file before trying to use it, I can see nothing wrong. Can you show use the HTML of your page?
    – IceMetalPunk
    Nov 20 at 15:43










  • I've updated the question to show the html layout and inclusion of script files.
    – Mark
    Nov 20 at 15:45










  • I don't know much about how ASP.net does its templates, but I do notice you're including fmp.js all the way at the bottom of your page. That means it'll load last, after everything else, so I'm guessing you're probably trying to access fmp before it's even been loaded.
    – IceMetalPunk
    Nov 20 at 15:53






  • 1




    So when you log fmp.layout, you get that, but if you try to call fmp.layout.setLayoutHeight() in the same place, it says it's undefined? That doesn't make a lot of sense...
    – IceMetalPunk
    Nov 20 at 16:08
















Please see comments. That was a copie/paste typo. I do return _fmp.
– Mark
Nov 20 at 15:41




Please see comments. That was a copie/paste typo. I do return _fmp.
– Mark
Nov 20 at 15:41












Assuming you're returning it as you say, and that you're including your external file before trying to use it, I can see nothing wrong. Can you show use the HTML of your page?
– IceMetalPunk
Nov 20 at 15:43




Assuming you're returning it as you say, and that you're including your external file before trying to use it, I can see nothing wrong. Can you show use the HTML of your page?
– IceMetalPunk
Nov 20 at 15:43












I've updated the question to show the html layout and inclusion of script files.
– Mark
Nov 20 at 15:45




I've updated the question to show the html layout and inclusion of script files.
– Mark
Nov 20 at 15:45












I don't know much about how ASP.net does its templates, but I do notice you're including fmp.js all the way at the bottom of your page. That means it'll load last, after everything else, so I'm guessing you're probably trying to access fmp before it's even been loaded.
– IceMetalPunk
Nov 20 at 15:53




I don't know much about how ASP.net does its templates, but I do notice you're including fmp.js all the way at the bottom of your page. That means it'll load last, after everything else, so I'm guessing you're probably trying to access fmp before it's even been loaded.
– IceMetalPunk
Nov 20 at 15:53




1




1




So when you log fmp.layout, you get that, but if you try to call fmp.layout.setLayoutHeight() in the same place, it says it's undefined? That doesn't make a lot of sense...
– IceMetalPunk
Nov 20 at 16:08




So when you log fmp.layout, you get that, but if you try to call fmp.layout.setLayoutHeight() in the same place, it says it's undefined? That doesn't make a lot of sense...
– IceMetalPunk
Nov 20 at 16:08


















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53396402%2ffunction-undefined-external-js%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Create new schema in PostgreSQL using DBeaver

Deepest pit of an array with Javascript: test on Codility

Fotorealismo