Javascript - Load A Script Synchronously With RequireJS?

Mar 7, 2011

I am using RequireJS in ASP.NET. There is a user control that includes a script file, and registers a startup script in order to initialize itself. Here's the generated code:

<script src="script/UserControls/myctrl.js" type="text/javascript"></script>
...
<script type="text/javascript">[code]....

So, the problem is that startup script runs before the myctrl.js file has had a chance to run. Currently, the require call uses a callback function, which obviously doesn't run until later, and this is the problem... the script returns and the browser continues to the startup script before MyCtrl has been created.

I have tried simply calling require(['script/dep1', 'script/dep2']); at the top of the file, but that doesn't block either, and the script fails because the dependencies haven't loaded yet. The dependencies are modules, by the way, e.g. they use define().Is there a way to load a script file synchronously with RequireJS? The API documentation says that "Using RequireJS in a server-side JavaScript environment that has synchronous loading should be as easy as redefining require.load()",

View 1 Replies


Similar Messages:

JavaScript - Why Are Pages Getting Accessed Synchronously

Mar 3, 2010

I have a Menu page. If a user selects an Menu Item it opens a new IE Window using JavaScript. So user can open different parts of applications in multiple IE Windows. These Windows have the same Session.

My issue is that these pages are accessed synchronously? If one of the child window is waiting for an action to be finished no other request from any other child window is processed. Is it because of using Session variables?

Update: This is only happening to the windows having the same parent. If I have IE child windows from different parent windows then this issue is not there.

View 2 Replies

Cannot Make Fading And FadeOut Act Synchronously?

Jan 29, 2010

I'm trying to use jquery to animate between two images, fading one out then fading the other in.However, I cannot get them to act syncronously, the fadeIn() always gets called before the fadeOut() is complete:

$(function() {
var tabContainers = $('#tabwrap > div');
var listItems = $('#tabwrap ul.tabnav li');[code]....

[EDIT] This is running in an ASP website, if that makes any difference whatsoever?

View 4 Replies

Why Doesn't 3.5 Always Load An External JavaScript

Oct 10, 2010

I have an external JavaScript in an asp.net 3.5 project. While writing different functions, sometimes the JavaScript is loaded into FF and sometimes it is not (based on FireBug) and the JavaScript does not run.
Even if there is an error in the JS it should still load or be visible to the browser, right?

What is the logic behind when it is loaded and when it doesn't load (or is accessible to the browser?)

Master Page loads JS from a script directory in project:

[code]...

View 1 Replies

Javascript - How To Load An Image Asynchronously

Jul 27, 2010

On the home page of my site I want to display a lot of products which have images which are quite large. Currently the page is taking so long to load that it is actually timing out and the page fails to display!

In MVC, or just ASP.NET in general, how can I load an image asynchronously? Basically what I want to do is display the details of the product and just display a small loading image e.g. ajaxload.info. until the image is loaded.

I assume this is going to require some javascript/jQuery...

View 2 Replies

Javascript - How To Load Html In <iFrame>

Feb 14, 2011

I am storing html of error pages of my site in sql table, i want to display them in a window, on the admin side, but not able to load the saved html in iframe, i am using asp.net mvc2.

its needed to save the pages, and display later to admin.

View 1 Replies

C# - Calling Javascript At Page Load?

Jun 21, 2010

I have a Javascript. I want to call only at page load. I dont want to call at postbacks.. (Asp.net 3,5)

View 5 Replies

Load A Javascript Function While Page Loads

Feb 18, 2011

I want to run a javascript function when the page loads. But as my page derives from the master page there is no form . The is my aspx file

<%@ Page Title="" Language="VB" MasterPageFile="~/Site.Master" AutoEventWireup="false"
CodeFile="test3.aspx.vb" Inherits="test3" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="Server">
<script language="javascript">
var m_Names = new Array();
function LoadArray() {
PageMethods.Load_Array(onSucceeded, onFailed);
}
function onSucceeded(result, userContext, methodName) {
m_Names = result;
}
function onFailed(error, userContext, methodName) {
alert("An error occurred")
}
</script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="Server">
<asp:ScriptManager ID="ScriptManager1" runat="server" EnablePageMethods="true">
</asp:ScriptManager>
<asp:TextBox ID="txt_model_code" runat="server"></asp:TextBox><br />
<br />
<input type="button" value="db Function" /><br />
</asp:Content>

I want to run the LoadArray() function initialy when the page loads. This function is calling a pagemethod given in aspx.vb code file..

Partial Class test3
Inherits System.Web.UI.Page
<System.Web.Services.WebMethod()>
Public Shared Function Load_Array() As String()
Dim Model_Name_old As String()()
Dim mod_code As String()
Dim mod_name As String()
Dim cod_upper As Integer
//calling webservice that retunrs a jagged array
Dim ins As New localhost_insert_model.dbModel
Model_Name_old = ins.get_Model_Name("A")
mod_code = Model_Name_old(0)
mod_name = Model_Name_old(1)
Return mod_name
End Function
End Class

So how can i load the javascrip LoadArray() function onPageLoad in this scenario?

View 4 Replies

C# - Passing Data To JavaScript On Page Load?

Apr 28, 2010

I want to pass data to id

<script language="javascript" src="/foo.aspx?id=1"></script>

I have this code in a aspx page.

The data should be passed on load, before this code is being executed.

how can i do that?

View 3 Replies

Javascript - How To Show Popup During Page Load

Mar 30, 2011

i have a requirement to show javascript Ok/Cancel option on page load. So, when the user is redirected from the previous page to this page, based on some logic in the query string, we have to display javascript OK/Cancel (page is not yet rendered here). Once the user clicks, we have to load different type of data (server side execution) based on OK/Cancel. what is the best way of accomplishing this task?

View 3 Replies

Javascript - Stop IFrames To Load From Code Behind?

Nov 18, 2010

I have an ASP.NET page and have a couple of linkbuttons and Iframes. The pages in side of these IFrame take long time to load, I want the user to navigate to another page by clicking one of the linkbuttons. Now, it looks like it is waiting for the the iframes to finish loading when i click on a link button, the page is still trying to load (instead of navigating to different page).

Is there any way I can stop the iframes to load and go to another page?

View 1 Replies

Execute JavaScript On AJAX Panel Load?

Dec 23, 2010

I want to run a JavaScript function to initialize some controls.

My problem is that the controls are on a Telerik control's form template that is displayed using AJAX.

Is there a way to specify the JavaScript function executes whenever this template is displayed?

View 1 Replies

Javascript - Running A JS Method On Load From Code Behind?

Mar 10, 2011

I am trying to load the following JS method:

<script type="text/javascript">
function initialize(lon,lat) {
var myLatlng = new google.maps.LatLng(lon,lan);
var myOptions = {
zoom: 14,
center: myLatlng,
mapTypeId: google.maps.MapTypeId.ROADMAP
}
var map = new google.maps.Map(document.getElementById("map"), myOptions);
var marker = new google.maps.Marker({
position: myLatlng,
map: map
});
}
</script>

In my code behind in VB.NET I then want to load such as:

initialize(53.349803617967446, -6.260257065296173)

I need to load in code behind since I have to get the longtidude and latidude from DB.

View 4 Replies

AJAX :: Javascript In Updatepanel Only Running Once On Load?

Jul 27, 2010

I have a piece of inline java script which is within an AJAX updatepanel. The code works perfectly on 1st load but not when the updatepanel is updated.

My script is as follows:

<script type="text/javascript">
var flashvars = {};
flashvars.galleryURL = "Photo_gallary/personal.xml";
var params = {};
params.bgcolor = "000000";
params.allowfullscreen = true;
params.allowscriptaccess = "always";
swfobject.embedSWF("Photo_gallary/simpleviewer.swf", "flashContent", "100%", "250", "9.0.124", false, flashvars, params);
</script>

As this is not a function how do I put it in the ScriptManager.RegisterStartupScript - which is I think what i have missing.

View 5 Replies

Use Javascript To Open A New Window On Page Load?

Jan 19, 2010

i have aspx pages with vb.net in the back. I need to use javascript to open a new window on page load. I am also sending a querystring (www.mysite.com/default.aspx?dest=register.aspx) from the previous page. I need the javascript to parse the querystring and open the new window only if the URL has a querystring.

View 4 Replies

Web Forms :: How To Execute Javascript Function On Page Load

Apr 23, 2010

I have created javascript function as mentioned below to hide/show some control. I am calling this script on dropdown on 'onchange' method. In dropdown first item is "-- Select --". I want to execute it on Page Load function, so by default it will be hidden. I tried to call like this on Page load, but it is not working.

ddlEmpType.Attributes.Add("onchange", "HideDD('-- Select --');");

[Code]....

View 8 Replies

C# - How To Load Javascript Files In Client System Once And Reuse Them

Feb 20, 2010

I have a large scale application which uses javascript for many reasons. these javascript files included in some JS files and JS files imported to Asp.net Masterpage files.

this JS files contents (javascript functions) will add to page when page display to user, so a Bunch of waste Javascript functions will include in Asp.net pages.

I'm lookingfor a way which these JS files downloads to users computer (any where, e.g: temporary internet files or some where else) and the Asp.net page use that functions which downloaded with page.

I also want to download 1 time ( per user login or per Open Session ) to users computer.

So How to download JS file to Users PC and Use them in Asp.net Pages

View 4 Replies

Adding Javascript On Initial Load After Updating UpdatePanels?

Mar 24, 2011

On my Page_Load command for a page, I have a couple of tests that are performed before the screen is displayed with an alert box displaying if the user cannot access the screen. If Not Page.IsPostBack Then

UpdatePanel1.ContentTemplateContainer.Controls.Add(ctl)
UpdatePanel1.Update
UpdatePanel2.ContentTemplateContainer.Controls.Add(ctl)

[code]...

View 1 Replies

Load The Entire Page Before Issuing An Alert Window Using Javascript

Jan 23, 2011

How am I be able to load the entire page before issuing an alert window using javascript.

Code:

[code]...

View 3 Replies

Using Javascript Inside A Dynamically Load UserControl In JQuery Ui Tabs

Jan 25, 2011

I need to insert some JavaScript code inside a UserControl that I load from an Ajax call via jQuery Ui Tabs. Let me explain... This is my View (with jQuery loaded)

<script type="text/javascript">
$(document).ready(function () {
$("#tabs").tabs({
cache: false,
});
getContentTab (1);
});
function getContentTab(index) {
var url='<%= Url.Content("~/Home/getUserControl") %>/' + index;
var targetDiv = "#tabs-" + index;
$.get(url,null, function(result) {
$(targetDiv).html(result);
});
}
</script>
<div id="tabs">
<ul>
<li><a href="#tabs-1" onclick="getContentTab(1);">Nunc tincidunt</a></li>
<li><a href="#tabs-2" onclick="getContentTab(2);">Proin dolor</a></li>
<li><a href="#tabs-3" onclick="getContentTab(3);">Aenean lacinia</a></li>
</ul>
<div id="tabs-1">
</div>
<div id="tabs-2">
</div>
<div id="tabs-3">
</div>
</div>
With these lines of code I call the Ajax function to load the content into a DIV.
This is the Action from the controller:
public ActionResult getUserControl(int num)
{
return PartialView("TestUC", num);
}
And this is the UserControl...
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl" %>
Number... <span id="testSpan"><%=Model.ToString() %></span>!!
<input type="button" value="Click me!!" onclick="message();" />
<script type="text/javascript">
function message(item) {
alert($("#testSpan").html());
}
</script>

The problem is that the message() function returns always 1 (instead of returning the correct number). My question is... How should I add the script to my UserControl in order to have my code running correctly?

View 2 Replies

Can Large External JavaScript Files Slow Down The Page Load Time

Aug 4, 2010

When we include Javascript files in our aspx files. either we write all the Javascript code in the Head section of aspx or we link to an external Javascript file.

So when the clinet makes a call to that page. Does that mean that all the Javascript will be loaded on the client side?

If that is the case then does not that mean that it will slow down the loading of page as all the Javascript has to be loaded on the client machine?

View 3 Replies

Web Forms :: How To Call A Javascript Function From CodeBehind On Page Load Event

Jan 20, 2011

How would you call a Javascript Function from CodeBehind on Page Load event without : Ajax (ScriptManager), Response.Write ?

View 2 Replies

C# - Direct JavaScript/css Requests To Same Server As Page In Load Balanced Environment

Jan 28, 2011

I have a .net web application in a load balanced environment over 3 servers. The load balancing is done with a load balancer. My site is [URL]with serveral javascript files such as [URL]

Is it possible to set it up that when request goes to server1 for [URL] then all javascript, css requests also go to server1, server2 or server3? Is there any web.config configuration that can be put in place to handle this?

View 1 Replies

Javascript - Getting IE Page Load Error On The Left Hand Bottom Of The Screen?

Oct 8, 2010

I have this code in my view..

<div>
<input type="button" value="Cancel" id="btnCancel" onclick="window.location.href='../Reviewer'" /> <input type="submit" value="Save" id="btnSave" onclick="saveCreateHeader()"/><input type="button" style="margin-left:50px;" id="btnNextStep" value="Next Step"[code]....

due to this code I am getting a pageload error? is that something wrong with this?this is the Error I am getting in IE.Webpage error details

User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; GTB6.5; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C; .NET4.0E; InfoPath.2; OfficeLiveConnector.1.5; OfficeLivePatch.1.3; AskTbF-ET/5.8.0.12304)
Timestamp: Fri, 8 Oct 2010 19:30:36 UTC


Message: Expected ';'
Line: 273
Char: 21
Code: 0
URI: http://localhost:25973/ProductTemplate/CreateHeaderIndex/42567

View 3 Replies

Web Forms :: Load JavaScript File Dynamically When User Control Is Loaded

Jun 17, 2013

I have a tab control on my page  and on click of tab  user control is loaded dynamically.I need to load the javascript file  of that user control dynamically. I don't want to add the reference of my js file on parent page.so in my .ascx page load event i added:

System.Web.UI.HtmlControls.HtmlGenericControl js = new System.Web.UI.HtmlControls.HtmlGenericControl("script");
js.Attributes["type"] = "text/javascript";
js.Attributes["src"] = "../../js/DatesJavaScript.js";
Page.Header.Controls.Add(js);
 
but it is not working.

View 1 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved