I am trying to get the standard Visual Studio 2012 MVC4 Internet template and oAuth to work but it won't!
So here are the simple steps to recreate.
Create new MVC4 Inernet Application
In Package Manager console execute: update-package
Un-comment OAuthWebSecurity.RegisterGoogleClient() in file AuthConfig.cs (I was under the impression that the Google oAuth does not need a key so un-commenting this line in the AuthConfig.cs file would enable it.)
F5 to run app
at this point I see the following error:
Error when entering login page:
Unhandled exception at line 115, column 5 in http://localhost:63180/Scripts/jquery.unobtrusive-ajax.js
0x800a01b6 - Microsoft JScript runtime error: Object doesn't support property or method 'live'
Click the login link on home page
Click the Google Button
at this point I get this error:
ProtocolException was unhandled by user code
No OpenID endpoint found
The cause of the error and the solution
The cause is that jquery-unobtrusive-ajax.js who is in charge of supporting the unobtrusive ajax in ASP.NET MVC using jQuery live method. But this method was deprecated in jQuery 1.7 and has been removed in 1.9.
This method allowed an event associated with any DOM element present or future.
The method to be used in place of live currently is the method on.
However the syntax is a bit different, since the method has more uses on jQuery.
$ ("form [data-ajax = true].") live ("submit", function (e) { ... }
modify the call to live with a call to on.
For on act like we happen to live on 3 parameters:
The event (like live, will "submit")
A selector (elements "children") is based selector which must always exist
The handler function (like live).
In this case our line looks like:
$ ("body"). on ("submit", "form [data-ajax = true]", function (e) { ... }
I moved the selector to the second parameter of on and have made you a basic selector "body" (not the most optimal, but well I'm sure there always).
The idea is that the last function is associated with all current and future elements of type form [data-ajax = true] that are within the selector base (body).
For all other calls to live (there are 3 more) make the same substitution that we be as follows:
$ ("body"). on ("click", "form [data-ajax = true]: submit", function (e) { ... }
$ ("body"). on ("click", "a [data-ajax = true]", function (e) { ... }
$ ("body"). on ("click", "form [data-ajax = true] input [type = image]", function (e) { ... }
And ready! With this we have recovered ajax functionality MVC unobtrusive and your application should work properly again!
translated from: http://geeks.ms/blogs/etomas/archive/2013/01/18/jquery-1-9-y-el-unobtrusive-ajax-de-asp-net-mvc.aspx
The unobtrusive library in NuGet has not been updated and does not work with jQuery 1.9.
See Unobtrusive Ajax stopped working after update jQuery to 1.9.0
Related
I have written functions in the app script bound to a google sheet that validates sheet data and shows a pop up in the sheet when there is an error.
Now, I am calling same functions form API calls in a Node js application to return a validation response without interacting google sheet.
API calls are successful, function gets called but unable to initialize UI.
I just don't want to write duplicate functions for same purpose but without accessing UI.
I get an error that says Script error message: Exception: Cannot call SpreadsheetApp.getUi() from this context.
How do I solve this issue by retaining the UI calling functionality of the app script functions and also getting work done through API?
You can put the call in a try catch block.
try {
SpreadsheetApp.getUi();
} catch (f) {
// do nothing here
}
I am trying to use EPPlus to manipulate my xlsm template and download to client. I believe there is no issue with excel package as I am able to save the package locally. But I need content disposition to download to client when it is live...
I have tried many different ways, return file, return filecontentresult, return streamcontentresult but all result in the same unknown error (attached in screenshot, as I could not translate it)..
Solved... you cannot use Ajax to call excel export function in controller. instead, call directly using html action link and return file ActionResult and it will initiate download in client browser.
similar resolution can be found here.
Response.WriteFile() -- not working asp net mvc 4.5
I'm using Worklight Studio 6.0.0.20130917-1749 in 64 bit Eclipse Juno on OSX Lion.
I'm finding that if I put a call to WL.Client.invokeProcedure(), or even WL.Logger.debug() in a jQueryMobile (1.3.1) pagebeforeshow handler, it causes the design portion of the rich page editor to hang when I try to switch to that page.
$("#myPage").on("pagebeforeshow", function(){WL.Logger.debug("loading myPage...");});
If I double click on myPage in the Mobile Navigation view, the page doesn't display, and I am unable to switch to any other page in the app, or do anything with he design pane. The refresh button doesn't fix it (it just tries to load the same page and I am right back where I started) The only thing I can do is to close the html file and re-open it.
This seems to be caused by a missing definition for WL.StaticAppProperites in the code that is run in the RPE. If I look at the html source of the common resources for the app under chrome I see a definition:
<script>
// Define WL namespace.
var WL = WL ? WL : {};
/**
* WLClient configuration variables.
* Values are injected by the deployer that packs the gadget.
*/
WL.StaticAppProps = {
"APP_DISPLAY_NAME": "MyApp",
"APP_ID": "MyApp",
"APP_SERVICES_URL": "\/MyApp\/apps\/services\/",
"APP_VERSION": "1.0",
"ENVIRONMENT": "preview",
"LOGIN_DISPLAY_TYPE": "popup",
"LOGIN_POPUP_HEIGHT": 610,
"LOGIN_POPUP_WIDTH": 920,
"PREVIEW_ENVIRONMENT": "common",
"WORKLIGHT_PLATFORM_VERSION": "6.0.0",
"WORKLIGHT_ROOT_URL": "\/MyApp\/apps\/services\/api\/MyApp\/common\/"
};</script>
There are similar definitions in the generated HTML for the various environments. But looking in weinre, I see that there is no corresponding script injected into the html that is displayed in the RPE. The lack of a definition for WL.StaticAppProperties is causing the code in worklight.js to fail just before the definition of WL.Utils.
Is there any way for me to add WL.StaticAppProps = {} so that this would come before the code that gets injected to load worklight.js?
Is there any other workaround for this problem?
The editor is defining that WL.StaticAppProps property under-the-covers but it is in an additional injected .js file, not in an inline script block like in the running page. It's possible that the location of that script in the editor's markup is incorrect and we will investigate that.
However there's a larger issue here, which is that a page in the editor is not able to make calls to the Worklight server. Because the editor always needs to operate independently of whether a preview server has been published and started, it uses its own mechanism to load web resources into the Design pane. Therefore the origin server is not the Worklight development server and attempted calls to server-side logic will go unanswered. I believe this is more likely the reason for the hang scenarios you see.
A general recommendation is to use the editor to construct the page's UI markup and then start to wire in service calls after the UI is generally complete. At that point previewing the application should likely shift over to the Mobile Browser Simulator and/or native device testing. In order to continue to do incremental UI work in the editor you can also add some temporary conditional logic to avoid (or mock-up) server calls while doing design work, such as:
var designMode = true; // switch to false for real server preview
if(!designMode) {
// your service invocations here
}
I have a Rails 3.2.8 application that I have recently upgraded from 3.1, and I have converted all of the original application.js code to CoffeeScript. Most of it is working fine. However, I have a breadcrumb function that I call in several views that is not being found. For right now, I'm just throwing up an alert to see if it is working:
product_breadcrumb = (attr) ->
alert attr
That's in a file called product_search.js.coffee. It is being successfully compiled, and ends up looking like this:
(function() {
var product_breadcrumb;
product_breadcrumb = function(attr) {
return alert(attr);
};
}).call(this);
I guess that's right, I don't know. Anyway, in Firebug I'm getting:
ReferenceError: product_breadcrumb is not defined
Please note that this is after an Ajax call. I don't know why the function wouldn't be available though. It's just a function definition after all. Shouldn't it still be available to the rendered HTML from the Ajax call? I can't understand why the function can't be found.
This needs to be on the global scope, and then you need to call it that way.
You should write:
root = exports ? this
and name your function
root.product_breadcrumb
then you can call it elsewhere as expected.
See this answer for a much lengthier explanation.
I'm trying to access Dojo within my webapp, and having issues getting what I need. Specifically, I have a webapp in an iframe with different versions of Dojo loaded:
In Firebug, I can do this:
window.dojo.version; // 1.7
window.frames[0].window.dojo.version; // 1.0
(Note iframe is in same domain as parent)
In GreaseMonkey, I can't find either version of Dojo:
dojo // undefined
window.dojo // undefined
window.frames[0].window.dojo // undefined
I started looking into unsafeWindow which supposedly I shouldn't use. It gives me access to the window'd Dojo, but not the iframe'd dojo I actually want.
unsafeWindow.dojo.version // 1.7 (wrong version)
unsafeWindow.frames[0].dojo // undefined
unsafeWindow.frames[0].window.dojo // undefined
window.frames[0].window.dojo // undefined
window.frames[0].unsafeWindow // undefined
window.frames[0].window.unsafeWindow // undefined
I've tried withDoc but I suspect I'm using it incorrectly:
unsafeWindow.dojo.withDoc(window.frames[0].window, function(){
var dijit = unsafeWindow.dijit; // seems wrong; doesn't work
var widget = dijit.byId('someWidgetInsideIframe');
console.log(widget); // undefined
}, this);
Any suggestions on other things I can try to get access to Dojo 1.0 in the iframe? Or if not that, at least figure out how to get access to dojo widgets defined in the iframe using the Dojo I do have access to?
I would expect unsafeWindow.frames[0].window.dojo.version; to work when GM is running on the main page (see below). The fact that it doesn't is a bug in my opinion, but the lead GM dev might not agree. Consider filing a bug report.
However, Greasemonkey normally processes frames/iframes as though they were standalone pages (with some exceptions). This means that the script will fire once for the main page and once for each frame whose src matches the #include/#exclude/#match directives. This also means that things like window.frames[0] will not be defined in every pass.
You can tell you are in the right frame with code like this:
if (window.self == window.top.frames[0]) {
//-- Currently running in the target frame
unsafeWindow.console.log ("dojo.version:", unsafeWindow.dojo.version);
}
else
unsafeWindow.console.log ("These are not droids... Or, er something.");