I am trying to extend BIRT for include a Report Item that is based on a javascript widget. I am not able to figure out how to include the js files used by a widget in the reportitemPresentation. I went through the 'RotatedText' example and tried to override the onRowSets method:
public Object onRowSets( IRowSet[] rowSets ) throws BirtException
{
StringBuffer str = new StringBuffer();
Str.append("<script type="text/javascript" src="../../scripts/jquery-1.11.1.min.js"></script>
<script type="text/javascript" src="../../jqwidgets/jqxcore.js"></script>
<script type="text/javascript" src="../../jqwidgets/jqxbuttons.js"></script>">);
.....//added code to initialize the widget.
return str.toString();
This added the script in the body of HTML but did not execute. Please ignore the syntax errors as the script tag was correctly added in the HTML.
In addition, I also want to add the code to initialize the widget:
$("#jqxbutton").jqxButton({ width: '150', height: '25'});
How do I do the following:
Include the js files of a widget in the html head tag.
How to include the code to initialize the widget and set some properties for the widget. For eg. How can I add the code for
$(document).ready(){ // initialize the widget, add some properties};
What classes do I have to extend, which method to override? Any examples would be helpful. What is the right way to include the widget?
Related
I'm not good with script and I can't figure out what's going wrong with my execution.
The webpage is http://snmcsupport.com/map-js-test-page and it should be running a script that produces a clickable map. The script itself is extremely long so I won't paste it here, but you can see it if you click here
On my webpage, I have the markup necessary to run the script in the header
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js">
</script>
<script src="//cdnjs.cloudflare.com/ajax/libs/raphael/2.1.4/raphael-min.js">
</script>
<script src="//cdnjs.cloudflare.com/ajax/libs/qtip2/2.1.1/jquery.qtip.min.js">
</script>
On my webpage, I call the script
<div>
<script type="text/javascript" src="http://snmcsupport.com/wp-includes/js/app.js">
</script>
</div>
But I still can't get the code to run? The initial instructions from the developer also said:
The last step is to initialize the map by making the following script calls:
<script>makeaClickableMap.initialize(<your-document-object-model-handle>);</script>
where your-object-document-model handle can be anything actually:
a jQuery object like $("#map")
a Javascript Document Object Model like document.getElementById("map")
or a simple string like "map"
but I can't figure out what that means. If I try to put in the initialize command in my webpage I get a nasty cross-scripting error and it won't let me.
I'm running this on Wordpress using a Divi Child theme.
makeaClickableMap.initialize(<your-document-object-model-handle>);
//this is the element that will --^
//be used to contain your rendered map
The method makeClickableMap.initialize() expects you to pass it a reference of an HTML element where you want the map to appear. Elements can be identified by
their tag name (div, p, h1, etc.)
a class name <div class="className></div>
OR by id name, which I will demonstrate here:
Firstly, you;ll need an element with an ID associated with it, it should be placed inside the <body> tag:
<div id="map"></div>
underneath this tag, but still within the body tag, you'll need to include the makeClickableMap.initialise call and pass in the ID of this <div>:
<!-- Javascript solution: -->
<script>
makeaClickableMap.initialize(document.getElementById('map'));
</script>
<!-- notice that the id is just 'map' here -->
An alternative to the Javscript solution above is using jQuery as follows (you'll still need the div with the ID):
<!-- jQuery solution: -->
<script>
makeaClickableMap.initialize($('#map'));
</script>
<!-- notice the ID is prefixced with a '#' character-->
As I am new to yii..I didnt understand what is CClientscript and its methods..
could you please anyone help me to about
CClientscript
registerScriptFile()
scriptFilePosition()
and its properties and methods
What is the use with this in yii..
what is the difference between
$baseUrl = Yii::app()->baseUrl;
$cs = Yii::app()->getClientScript();
$cs->registerScriptFile($baseUrl.'/js/jquery-min.js');
and
<script type="text/javascript" src="<?php echo Yii::app()->request->baseUrl >/js/jquery-min.js"></script>
spent lot of time ..
please any suggestions ..thanks in advance..
By using CClientScript class we can manages JavaScript and CSS stylesheets for views dynamically.
if you add direct script or css file, In you views or layouts in below format
<script type="text/javascript" src="<?php echo Yii::app()->request->baseUrl >/js/jquery-min.js"></script>
which mean, you are rendering file from view in static position.
By using CClientscript we can render jquery in different position, like inside Head Tag, in Body Tag dynamically and this class will generate script tag and it will append in your html dynamically with dynamic position.
Predefined position in CClientScript as per Yii Doc:-
CClientScript::POS_HEAD : the script is inserted in the head section right before the title element.
CClientScript::POS_BEGIN : the script is inserted at the beginning of the body section.
CClientScript::POS_END : the script is inserted at the end of the body section.
CClientScript::POS_LOAD : the script is inserted in the window.onload() function.
CClientScript::POS_READY : the script is inserted in the jQuery's ready function.
I hope, you got the information about CClientScript.
I am trying to use GTM's "Custom HTML Tag" option with the following code but it is giving me the following error: Invalid HTML, CSS, or JavaScript found in template.
I've seen other threads where it looks like GTM doesn't work well with certain tag attributes. I'm wondering which one in my code is breaking it. Otherwise the code seems to be standard javascript:
<!-- Add script to header tag-->
<script type="text/javascript" src="https://staygrid.com/js/hapi/web.js?v="20150809"></script>
<script type="text/javascript">
var hlWebEngine = new HotelogixWeb();
function drawEngine()
{
var options = {
container: document.getElementById("webDiv"),
hotelId: "QV5TX0ZSczM0Xzc5Nl9GNXRlcjkwODdzXylkaGZfZHJ0ZXI3Xzc5Nl9oZ2ZoX2deZDg1NA==",
languageId: 1
};
hlWebEngine.draw(options);
}
hlWebEngine.run(drawEngine);
</script>
<!--Div that will hold the web engine-->
<div id="webDiv" style="border-width: 0"></div>
Remove the extra double quotes before your "v" query parameter value, so that it looks like this:
src="https://staygrid.com/js/hapi/web.js?v=20150809"
At least that did the trick for me when I tried it out in my own container.
your src attribute use like given below i think it will work
<script type="text/javascript" src="https://staygrid.com/js/hapi/web.js?v='20150809'"></script>
I'm building a Seaside application and I'm searching for a way to highlight some code snippets on the browser with JS.
I found highlight.js which support Smalltalk syntax but it doesn't work.
I add this script and hljs.initHighlightingOnLoad(); in the header but it doesn't work.
Probably I miss something but what?
I use highlight.js from CDN:
<link href='http://yandex.st/highlightjs/8.0/styles/sunburst.min.css' rel='stylesheet'/>
<script src='http://yandex.st/highlightjs/8.0/highlight.min.js' type='text/javascript'/>
I also define a format function like:
function format(){
var b=document.getElementsByTagName("pre");
for (i=0;i<b.length;i++) {
hljs.tabReplace = ' '; // 2 spaces
b[i].style.fontSize = '0.9em';
hljs.highlightBlock(b[i],' ',false);
}
}
and use
<pre class="smalltalk"><code>……</code></pre>
for highlightable block. Then I call format() when the page is loaded (or a dynamic content with code is loaded into page)
I'm working with ASP.Net MVC4 wiht view engine Razor. I like put mask date and time in TexBoxFor I installed for nugget jquery.maskedinput-1.3.min.js and add in the view
(document).ready(function () {
$("#FechaDen").mask("99/99/9999");
$("#HoraDen").mask("99:99:99");
});
But I have this error: Uncaught TypeError: Object [object Object] has no method 'mask'
How I can resolve this problem?
You seem to have forgotted to reference the jquery.maskedinput plugin in your page:
<script type="text/javascript" src="#Url.Content("~/scripts/jquery.maskedinput-1.3.min.js")"></script>
Make sure that the path is correct and that the plugin is actually situated in this folder. Use the Network tab of a javascript debugging tool such as FireBug to ensure that there are no 404 errors with your script references.
Also make sure that you have added this script inclusion after jQuery. Be careful because in the ASP.NET MVC 4 Internet Project Template, the ~/Views/Shared/_Layout.cshtml file renders jquery as a bundle at the end of the DOM:
#Scripts.Render("~/bundles/jquery")
#RenderSection("scripts", required: false)
</body>
So if you are putting this reference inside your view make sure that this happens inside the scripts section:
#section scripts {
<script type="text/javascript" src="#Url.Content("~/scripts/jquery.maskedinput-1.3.min.js")"></script>
<script type="text/javascript">
$("#FechaDen").mask("99/99/9999");
$("#HoraDen").mask("99:99:99");
</script>
}
Also notice that since this script is now at the end of the DOM I have gotten rid of the $(document).ready call which is no longer necessary (and which you got wrong in the code you have shown because you forgot to prefix it with a $).