Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Managing Javascript library conflicts (Read 11934 times)
AT
YaBB Newbies
*
Offline



Posts: 7
Joined: Dec 21st, 2012
Managing Javascript library conflicts
Dec 21st, 2012 at 8:02pm
Print Post  
Hello,

I'm working on an MVC razor site that already uses Jquery, Jquery UI, and DevExpress MVC controls, and I'm running into a number of conflicts between the Javascript libraries required by MindFusion and my existing components. All I need is a static diagram image with no editing. Is there any way to simply render diagrams as an image on the server to eliminate all the Javascript conflicts?

Thanks,
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Managing Javascript library conflicts
Reply #1 - Dec 21st, 2012 at 9:00pm
Print Post  
Hi,

What kind of conflicts are you getting? You could call Diagram.CreateImage after adding and arranging diagram items to get a bitmap image, then call Image.Save to save it to a file, and finally render an IMG element to show the exported image in the browser.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
AT
YaBB Newbies
*
Offline



Posts: 7
Joined: Dec 21st, 2012
Re: Managing Javascript library conflicts
Reply #2 - Jan 2nd, 2013 at 5:47pm
Print Post  
Sorry, I did not realize you had responded until I checked back today. It seems as though the forum notifications are not working.

The javascript conflict was due to the fact that the MicrosoftAjax.js library required by MindFusion installs a "Type.prototype.registerClass" function which is incompatible with the DevExpress library. DevExpress installs its own version of this function.

I was able to temporarily work around this conflict by reordering my script declarations, but I'm not sure that is going to work long-term.

I will also try rendering the image and see how that works.

Thanks,
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Managing Javascript library conflicts
Reply #3 - Jan 2nd, 2013 at 6:15pm
Print Post  
What DevExpress library are you using exactly, are you sure it's not loading MicrosoftAjax.js from a different location, e.g. the Microsoft's content delivery network? In such case, it should be safe to skip loading a local MicrosoftAjax.js explicitly for the diagram control, as long as the diagramming.js comes after DevExpress script references.

Quote:
It seems as though the forum notifications are not working.


They should work but might be filtered as spam by your email software.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
AT
YaBB Newbies
*
Offline



Posts: 7
Joined: Dec 21st, 2012
Re: Managing Javascript library conflicts
Reply #4 - Jan 2nd, 2013 at 7:24pm
Print Post  
I'm using a couple of DevExpress ASP.NET MVC components and they are not loading MicrosoftAjax.js from anywhere (I've verified the loaded libraries with an http proxy). I've already tried and the Mindfusion components do not work without loading the Microsoft library.

My email provider is Google and the notifications are definitely not working at all (email address is correct and they are not going to my spam folder).

Thanks,
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Managing Javascript library conflicts
Reply #5 - Jan 3rd, 2013 at 4:30pm
Print Post  
I have installed DevXpress and tried their Dxperience ASP.NET MVC Web App template. The wizard crashed for me and the application won't build, but I can see the project has a reference to System.Web.Extensions.dll. This assembly loads MicrosoftAjax.js from its embedded resources, so I guess that's where registerClass comes from. I'll try some of the other templates to see if they'll work better and see if diagramming.js can load without the standalone microsoftajax.js.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Managing Javascript library conflicts
Reply #6 - Jan 3rd, 2013 at 6:54pm
Print Post  
DevXpress crashed under VS2010 but works fine under VS2012. So I have created a project from their Dxperience ASP.NET MVC Web App template, and added a few lines to the Home/Index.cshtml view:

Code
Select All
<script src="../../Scripts/MindFusion.Diagramming.js"></script>
@model System.Collections.IEnumerable
@using MindFusion.Diagramming.Mvc

@Html.Partial("GridViewPartialView", Model)


@{var viewModel = new DiagramView("diagramView1");}
@Html.DiagramView(viewModel) 



This shows the DiagramView canvas correctly below the sample DevXpress grid, without explicitly loading MicrosoftAjax.js. However the project already contains MicrosoftAjax.js under the Scripts folder, so I suppose it gets loaded at some point by a different control.
  
Back to top
 
IP Logged
 
AT
YaBB Newbies
*
Offline



Posts: 7
Joined: Dec 21st, 2012
Re: Managing Javascript library conflicts
Reply #7 - Jan 3rd, 2013 at 7:21pm
Print Post  
Thanks for the follow-ups. When I try running without the MS Ajax libraries I get the following errors when the javascript inserted by HTML.DiagramView is executed:

Uncaught ReferenceError: Type is not defined
Uncaught ReferenceError: Sys is not defined

As I said, I was able to get this working in a top-level view by including the MS Ajax libraries after the DevExpress scripts, however, I was unable to get it working when loading the diagram canvas with an AJAX callback to a partial view. When loaded from a partial view the javascript normally inserted by HTML.DiagramView is completely missing.

In any case, I've gotten this working by rendering a server-side image dynamically and since that will meet my needs I do not intend to further pursue any of these other methods.

Thanks,
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint