How to use MathJax inside polymer dart element? - dart

I am trying to use MathJax inside a polymer.dart element:
<script type="text/javascript"
src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML">
</script>
Any help would be appreciated. Update: Using this:
MathJax.Hub.Queue(["Typeset",MathJax.Hub,"myDivWithMath"]);

MathJax very probably tries to find the element by using querySelector('myDivWithMath') which doesn't work because this selector doesn't find the element.
You can try
MathJax.Hub.Queue(["Typeset",MathJax.Hub,"* /deep/ myDivWithMath"]);
don't use shadowDOM by adding the attribute 'lightdom' to the element. This is the only reference I found how to do this How to skip the Shadow DOM (and use the Light DOM) instead for Polymer templates (never used this myself yet).

Related

Thymeleaf add css styles to html from variable

Let's say I have a variable cssStyles which contains some css as String. I want to send it in my html file in this way
<style>
${cssStyles}
</style>
How can this be achieved with thymeleaf?
Thanks!
At the very least you need to mark the style object that you'r using inline thymeleaf and use proper inline syntax. Below a mock of what I think might work.
See https://www.thymeleaf.org/doc/tutorials/2.1/usingthymeleaf.html#inlining for more information on how to do thymeleaf inlining
<style th:inline="text">
[(${cssStyles})]
</style>

what means ${demo.css} in example files of highcharts ? That piece of code seems to be literal

what means ${demo.css} in example files of highcharts ? That piece of code
<style type="text/css">
${demo.css}
</style>
seems to be literal
This looks like a jQuery template tag to load a non-existent CSS file. According to this Highcharts form post it is not required, and all configuration should be managed through Javascript rather than CSS.
The Highcharts API Reference lists all of the Javascript configuration items.

Dart Exception: Already registered (Polymer) prototype for element x

I've two polymer elements that share the same dart file. In the dart file I declare both the PolymerElement classes.
Until polymer 0.15.0+1 it was working fine.
I've updated the project to polymer 0.15.1 and now I get this exception:
Exception: Already registered (Polymer) prototype for element x
Where x is the first polymer.
I think the polymer transformer is trying to register it two times, the first scanning the x polymer html file, the second when scanning the other element html file.
An issue has been open in dart: https://code.google.com/p/dart/issues/detail?id=21332
I don't know about Dart and whatnot, but I had the same error message in my console. Turns out I was still having the noscript attribute in my element declaration, which is wrong if you want to register your element manually.
Removing noscript from the element declaration solved the problem.
The issue has been "resolved" with the release 0.15.1+2 of Polymer Dart.
The compiler now throws a warning, and as stated in the issue comments: "The real solution for you here should be to put your script file in its own html file, and import that instead of your script. In summary you have to create an HTML file (e.g. script_thats_used_multiple_times.html) with the following content:
<!DOCTYPE html>
<script type="application/dart" src="script_thats_used_multiple_times.dart"></script>
then of course delete the original from all polymer components that used this file previously and put the import above the
<link rel="import" href="script_thats_used_multiple_times.html">
which will import previously created HTML file. Simple."

Jquerymobile and jquery ui data icon conflict

In my web app, I have a page where I use autocomplete widget from jQuery UI.
I link to jQuery Mobileand jQuery UI CSS from this page.
link rel="stylesheet" href="Styles/jquery.mobile-1.0.1.min.css"
type="text/css" link rel="stylesheet" type="text/css"
href="Styles/ui-lightness/jquery-ui-1.8.16.custom.css"
when I do this, my jQuery Mobile data-icons dont show at all. I just see a black hole in place. The other pages where I refer to only the jQuery Mobile have no issues. they display the data-icons fine.
Any idea as to what I could be doing wrong?
Put the jQuery UI css link BEFORE the jQuery mobile css and should work.
Try linking your Javascripts in the followng order:
<script src="custom-scripting.js"></script>
<script src="jquery-mobile.js"></script>
If this doesn't help, try using the custom selector in your code :jqmData(), as it automatically incorporates namespaced data attributes into the lookup when they are in use. For example, instead of calling $("div[data-role='page']"), you should use $("div:jqmData(role='page')"), which internally maps to $("div[data-"+ $.mobile.ns +"role='page']") without forcing you to concatenate a namespace into your selectors manually specially for your data-icons
jQuery mobile shows the icon through a background-image and position CSS declaration, it's likely you have CSS that is overriding those styles.
To find your issue, use your debugger, Chrome's debugger is especially useful, under Computed Style look for the background-image/position style and the CSS class in conflict. Then you can see which class is winning and the actual value, if you see a black box you may very well just have a bad url to the image - which you can identify here as well by following the image link on the CSS style and seeing if that image really exists.
Also I don't see your < and > brackets around your CSS declaration, correct me if I'm wrong but I think you're supposed to link to each css file with a separate tag:
<link rel="stylesheet" href="Styles/jquery.mobile-1.0.1.min.css" type="text/css">
<link rel="stylesheet" type="text/css" href="Styles/ui-lightness/jquery-ui-1.8.16.custom.css">

Microsoft JScript runtime error: '$' is undefined

I am trying to hide/show elements in a view using following code:
$('buttonClass/IDhere').click(function (){
$('theDivYouWantToShowClass/IDhere').toggle();
});
However, I am keep getting
Microsoft JScript runtime error: '$' is undefined
What might be the issue and how do I fix it?
This thread is pretty old, but I think an answer in the thread would be nice. I agree with the previous two answers - it's likely because jQuery wasn't loaded. You can load it this way (usually toward the top of the file):
<script src="~/Scripts/jquery-1.9.1.js" type="text/javascript"></script>
<script src="~/Scripts/jquery-1.9.1.min.js" type="text/javascript"></script>
(or whatever the current version of jQuery is).
Hope it helps.
It sounds like jQuery hasn't been loaded yet.
did you make sure download the jquery javascript file and link in to your html/aspx page before attempting to use jquery scripting?
you need to:
download the jquery code/file from:
http://jquery.com/
copy the file (jquery-1.8.3.min.js) you just downloaded somewhere into your web project directory/folder
then insert the link to this file into html/aspx page:
now try to run webpage
references:
www.youtube.com/watch?v=Bf9Gs-09uzQ
www.ajaxtutorials.com/javascript/introduction-to-jquery-learn-jquery-from-scratch-in-asp-net-4-0/
$ is defined by default when you load jquery. I would try and use jquery() to see if somehow $ is being unloaded etc. You can also load up firebug and hit the page. It should show up as a global variable/function. NOTE: You can also setup jquery to not setup the short hand "$".
since it looks like your trying to target classes and ID's - try this
$('.buttonClass #IDhere').click(function (){
$('.theDivYouWantToShowClass #IDhere').toggle();
});
This is a definite case of jQuery module not being loaded. In my case, common.js had a jQuery related script
$( document ).ready(function() {
var divSessionWarning = $("#idivWarn");
divSesWarning.load(divSesWarning.data("src"));
});
This was called in header.jsp. Swapping the sequence of loading the jQuery followed by the common.js resolved the issue.
<script language="javascript" type="text/javascript" src="/JAVASCRIPT/jquery/jquery-1.10.2.min.js"></script>
<script type="text/javascript" src="/JAVASCRIPT/mod/common.js"></script>
Hope this helps.
If jQuery is called then make sure jQuery is loaded before the stylesheet as its likely that calls it

Resources