Jssor non-jquery slider dynamic amount multiple slider on one page - jssor

How can I put dynamic amount multiple slider on a single page? I could use 2 sliders on a page as follows:
<script>
jssor_sliderb_starter1 = function (containerId) {
...
};
jssor_sliderb_starter2 = function (containerId) {
...
};
<div id="sliderb_container1">
...
<script>
jssor_sliderb_starter1('sliderb_container1');
</script> </div>
<div id="sliderb_container2">
...
<script>
jssor_sliderb_starter2('sliderb_container2');
</script> </div>
But what if I dont know the amount of the sliders? Please help..

I have added 4 identical sliders on my page with different images and captions and used the following code and it works fine.
<!-- Jssor Sliders -->
<script>
jssor_sliderb_starter = function (containerId) {
...
};
</script>
<!-- Jssor Slider Begin -->
<div id="sliderb_container1" class="sliderb_con">
...
<script>
jssor_sliderb_starter('sliderb_container1');
</script>
</div>
<div id="sliderb_container2" class="sliderb_con">
...
<script>
jssor_sliderb_starter('sliderb_container2');
</script>
</div>
<div id="sliderb_container3" class="sliderb_con">
...
<script>
jssor_sliderb_starter('sliderb_container3');
</script>
</div>
<div id="sliderb_container4" class="sliderb_con">
...
<script>
jssor_sliderb_starter('sliderb_container4');
</script>
</div>
<!-- Jssor Slider End -->
So now if I add more sliders i will have to use different ids only. I was confused about how to use the ids to call the function and thought i have to write different functions for each slider. But the code worked. Thank You :)

<!-- Jssor Sliders -->
<script>
jssor_sliderb_starter = function (containerId) {
}
</script>
<div id="sliders">
<!-- Jssor Slider Begin -->
<div class="sliderb_con">
</div>
<div class="sliderb_con">
</div>
<div class="sliderb_con">
</div>
<div class="sliderb_con">
</div>
<!-- Jssor Slider End -->
</div>
<script>
var slidersElement = document.getElementById("sliders");
for (var tmpEl = slidersElement.firstChild; tmpEl; tmpEl =tmpEl.NextSibling) {
if (tmpEl.nodeType == 1) {
jssor_sliderb_starter(tmpEl);
}
}
</script>

Related

How to generate empty div for modal window when page is rendered first time?

Are you able to suggest how to generate an empty 'div' tag for a modal window when the page is rendered the first time?
'div' content will be fetched with ajax request.
I would like to avoid fetching modal window content twice - first when the page is rendered and then when I click on the link to show modal window.
I do not use wicket modal window implementation.
I have a base ModalBorder class.
ModalBorder.java
public class ModalBorder extends Border {
public ModalBorder(String id) {
super(id);
}
}
with ModalBorder.html markup
<wicket:border>
<div class="modal-background"></div>
<div class="modal-content">
<div class="box">
<wicket:body/>
</div>
</div>
</wicket:border>
AboutAppModalPanel.java
public class AboutModalPanel extends Panel {
public AboutModalPanel(String id) {
super(id);
setOutputMarkupId(true);
var mb = new ModalBorder("modalBorder");
mb.setRenderBodyOnly(true);
add(mb);
}
}
AboutAppModalPanel.html
<wicket:panel>
<div wicket:id="modalBorder">
<article class="media">
<div class="media-content">
<div class="content">
<p>
<strong>
About application content
</strong>
</p>
</div>
</div>
</article>
</div>
</wicket:panel>
I would like to achieve the below output:
MainPage.html
Page is rendered first time (with empty div)
<html>
<body>
...
<div class="modal" id="aboutAppModalPanel2">
<!-- modal is empty and hidden (not-active) -->
</div>
</body>
</html>
and then requesting modal content via ajax request
<html>
<body>
...
<div class="modal is-active" id="aboutAppModalPanel2">
<!-- modal is filled in and SHOWN (added 'is-active' class) -->
<div class="modal-background"></div>
<div class="modal-content">
<div class="box">
<article class="media">
<div class="media-content">
<div class="content">
<p><strong>About application content</strong>
...
</div>
</body>
</html>
but now I am facing this issue:
Page is rendered first time (with filled in div)
<html>
<body>
...
<div class="modal" id="aboutAppModalPanel2">
<!-- modal is filled in and HIDDEN (not-active) -->
<div class="modal-background"></div>
<div class="modal-content">
<div class="box">
<article class="media">
<div class="media-content">
<div class="content">
<p><strong>About application content</strong>
...
</div>
</body>
</html>
and then requesting modal content via ajax request
<html>
<body>
...
<div class="modal is-active" id="aboutAppModalPanel2">
<!-- modal is filled in and SHOWN (added 'is-active' class) -->
<div class="modal-background"></div>
<div class="modal-content">
<div class="box">
<article class="media">
<div class="media-content">
<div class="content">
<p><strong>About application content</strong>
...
</div>
</body>
</html>
Are you able to suggest a solution?
I use Wicket 9.
Add an empty WebMarkupContainer instead of your panel to the page, making sure you call setOutputMarkupId(true) so it can be refreshed in an ajax call. Then replace it with your panel in the Link's onClick(AjaxRequestTarget target) method.
thanks for a tip. I needed to change my implementation but now it works.
// In page constructor:
// Instead of empty WebMarkupContainer you suggested an empty panel with setOutputMarkupId(true)
add(new AjaxEmptyPanel("aboutApp"));
add(showAboutAppLink());
// and AjaxLink:
private AjaxLink<String> showAboutAppLink() {
return new AjaxLink<>("showAboutApp", new ResourceModel("SHOW")) {
private static final long serialVersionUID = -3035458028030059416L;
#Override
public void onClick(AjaxRequestTarget ajaxRequestTarget) {
var aboutApp = new AboutAppModalPanel("aboutApp");
aboutApp.setOutputMarkupId(true);
getPage().replace(aboutApp);
ajaxRequestTarget.add(aboutApp);
}
};
}

jQuery getJSON not working on Internet Explorer 11

I have a site that uses jQuery within the Codeigniter framework. It works perfectly in both Firefox and Chrome. However in IE the getJSON does not work, jQuery load() works but not getJSON. Ive tried the $.ajaxSetup{{cache:false}} among others but no joy.
var url="../../index.php/cslcontrol/";
$(document).ready(function(){
//hide divs with the class '.views' except the one with id of 'home'
$(".views:not('#home')").hide();
//function that ensures only the div related to the selected menubar icon is dislayed
$("li a[href]").click(function(){
//storing the value of the clicked list a href
var tabVal=$(this).attr('value');
//showing a div whose div name is the same as the value of the selected list ahref
$("#"+tabVal).show();
//keeping the other divs hidden
$(".views[id!="+tabVal+"]").hide();
});
$("#home_text").load("css/history.html #home_txt");
$("#eighties_text").load("images/Eighties_seasons.html h1, p");
$("#nineties_text").load("images/Nineties_seasons.html h1, p");
//making a ajax call to fill the champions table
$.getJSON(url+"titleWin", function(data){
$.each(data, function(){
$("#senior_champions").append("<tr><td>"+ this["Season"] + "</td><td>"+ this["Winner"] + "</td><td>" + this["Runner up"] + "</td><td>"+ this["Play off"] + "</td></tr>");
});
});
//making a ajax call to fill the senior cup table
$.getJSON(url+"senCup", function(data){
$.each(data, function(){
$("#senior_cup_finals").append("<tr><td>"+ this["Season"] + "</td><td>"+ this["Winner"] + "</td><td>" + this["Score"] + "</td><td>"+ this["Runner-up"] + "</td></tr>");
});
});
$.getJSON(url+"getClub", function(data){
$.each(data, function(){
$("#club_info").append("<a class=\"name\" role=\"button\" data-toggle=\"modal\" data-target=\"#modalCSL\">"+this["Club"]+"</a>");
});
var crests = [];
$.each(data, function(){
if(this["Image"]!=""){
crests.push("<img src=\"images/"+this["Image"]+"\" alt=\""+this["Image"]+"\" title=\""+this["Club"]+"\"/>");
}
});
$("#pix1").html(crests.slice(0, 5));
$("#pix2").html(crests.slice(5, 10));
$("#pix3").html(crests.slice(10, 15));
});
});
$(document).ajaxSuccess(function(event,xhr,settings){
//if(settings.url=="history.txt"){
// $("#home_text").append("<div class=\"home-images\">do</div>");
//}
if(settings.url==url+"senCup"){
$("#senior_cup_finals td:eq(26), #senior_cup_finals td:eq(30)").append("<sup> R</sup>");
$("#senior_cup_finals td:eq(34)").append("<sup> R-p</sup>");
}
if(settings.url==url+"titleWin"){
$("#champions td:eq(11)").append("<sup> R</sup>");
$("#champions td:eq(52)").append("<sup> Gr</sup>");
$("#champions td:eq(56)").append("<sup> Pr</sup>");
}
if(settings.url==url+"getClub"){
$(".name").click(function(){
var aref= $(this).text();
$(".modal-body").load("css/history.html h1:contains('"+aref+"'), h1:contains('"+aref+"')+p");
$(".modal-footer").html("<button id=\"butt\" name=\""+aref+"\" value=\""+aref+"\">"+aref+" honours</button><div id=\"dead\"></div>");
});
$("#club_info .name:last-of-type").css({"margin-right":"50%"});
}
if(settings.url=="css/history.html"){
$("#butt").click(function(){
var testing=$(this).attr('value');
var testclean=encodeURIComponent(testing);
$.getJSON(url+"getHonours?name="+testclean, function(data){
var honours=[];
$.each(data, function(){
honours.push("<table class=\"table\" id=\"honstab\"><tr><th>"+data[0]["Source"]+"</th><th>"+data[1]["Source"]+"</th><th>"+data[2]["Source"]+"</th><th>"+data[3]["Source"]+"</th><th>"+data[4]["Source"]+"</th><th>"+data[5]["Source"]+"</th><th>"+data[6]["Source"]+"</th><th>"+data[7]["Source"]+"</th><th>"+data[8]["Source"]+"</th></tr><tr><td>"+data[0]["COUNT(*)"]+"</td><td>"+data[1]["COUNT(*)"]+"</td><td>"+data[2]["COUNT(*)"]+"</td><td>"+data[3]["COUNT(*)"]+"</td><td>"+data[4]["COUNT(*)"]+"</td><td>"+data[5]["COUNT(*)"]+"</td><td>"+data[6]["COUNT(*)"]+"</td><td>"+data[7]["COUNT(*)"]+"</td><td>"+data[8]["COUNT(*)"]+"</td></tr></table>");
$("#dead").html(honours.slice(0,1));
$("#honstab td").each(function(){
if ($(this).html()=="0"){
trial=$(this).index();
$("#honstab th:eq("+trial+"), #honstab td:eq("+trial+")").remove();
if($("#honstab tr").html()==0){
$("#honstab").html("<tr><th>No Honours</th></tr></table>");
}
}
});
});
});
});
}
});
<!--Heres the view file-->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="shortcut icon" href="../../docs-assets/ico/favicon.png">
<link href='http://fonts.googleapis.com/css?family=Anton' rel='stylesheet' type='text/css'>
<title>Connacht Senior League</title>
<!-- Bootstrap core CSS -->
<link href="css/bootstrap.min.css" rel="stylesheet" type='text/css'>
<link href="css/main-style.css" rel="stylesheet" type='text/css'>
</head>
<body>
<div class="container">
<div class="row">
<div class="col-md-12">
<div class="heading">
<h1>Connacht Senior League</h1>
</div>
<nav class="navbar navbar-default" id="csl-navbar" role="navigation">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
<!--creates the toggle button that displays the menu in small screen formats-->
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#"></a>
</div>
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav" id="accordion" role="tablist" aria-multiselectable="false">
<li>Home</li>
<li class="dropdown">
<a class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">History<span class="caret"></span></a>
<ul class="dropdown-menu" role="menu">
<li>Eighties Seasons</li>
<li>Nineties Seasons</li>
</ul>
</li>
<li>Clubs</li>
<li>Champions</li>
<li>Senior-Cup</li>
</ul>
<!-- for the search and go form on the right of navbar-->
<form class="navbar-form navbar-right" role="search">
<div class="form-group">
<input type="text" class="form-control" placeholder="Search">
</div>
<button type="submit" class="btn btn-default">Go</button>
</form>
</div>
</nav>
<div id="home" class="views">
<div class="row">
<div class="col-xs-12" id="home_text">
</div>
<div class="col-xs-12" id="home_image">
<img src="images/home_page.png"/>
</div>
<div class="col-xs-12" id="ina_logo">
<img src="images/ina.PNG" width="30%"/>
</div>
</div>
</div>
<div id="eighties" class="views">
<div class="row">
<div class="col-xs-12" id="eighties_text">
</div>
</div>
</div>
<div id="nineties" class="views">
<div class="row">
<div class="col-xs-12" id="nineties_text">
</div>
</div>
</div>
<div id="clubs" class="views">
<div class="row">
<div class="col-xs-12">
<div id="club_info">
<div class="modal fade bs-example-modal-lg" id="modalCSL" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel" aria-hidden="true">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-body">
...
</div>
<div class="modal-footer">
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div id="champions" class="views">
<div class="row">
<div class="col-xs-12">
<h1>Champions</h1>
<p>The following table lists the League Champions and sides who finished Second. Goal differnece did not count so occassionally Play-offs were needed. An exception is the case of the 94-95 season where the League was split into two groups so a Play-off was mandatory. In 96-97 the season had Two divisions, the table only shows details of the Premier Division with First Division details in the footnotes</p>
<table class="table table-striped" id="senior_champions">
<tr>
<th>Season</th>
<th>Winner</th>
<th>Runner-up</th>
<th>Play off</th>
</tr>
</table>
<div class="notes"><p><a name="merv_salt" id="merv_salt"></a>R: 2nd Replay after two 2-2 draws</p>
<p><a name="straide" id="straide"></a>Gr: League split into 2 groups with group winners meeting in a play-off final. Top 3 teams in each group would go into a Premiership and the rest into a first division</p>
<p><a name="prem" id="prem"></a>Pr: This season had a Premiership and a First Division. Ballinasloe Town were First Division Champs.</p>
</div>
</div>
</div>
</div>
<div id="senior_cup" class="views">
<div class="row">
<div class="col-xs-12">
<h1>Senior Cup</h1>
<p>The following table lists details of the Senior Cup Finals. This was the main knockout competition involving the Connacht Senior clubs. However champions from the four junior leagues were also included and they are highlighted with a (J)</p>
<table class="table table-striped" id="senior_cup_finals">
<tr>
<th>Season</th>
<th>Winner</th>
<th>Score</th>
<th>Runner-up</th>
</tr>
</table>
<div class="notes"><p><a name="calry_merv" id="calry_merv"></a>R: Replay after 1-1 draw</p>
<p><a name="salt_calry" id="salt_calry"></a>R-p: Replay won on penalties after 1-1 draw</p>
</div>
</div>
</div>
</div>
</div>
</div>
<div id="carousel-example-generic" class="carousel slide" data-ride="carousel" pause="onload">
<!-- Wrapper for slides-->
<div class="carousel-inner" role="listbox">
<div class="item active" id="pix1">
</div>
<div class="item" id="pix2">
</div>
<div class="item" id="pix3">
</div>
</div>
</div>
</div>
<!--[if lt IE 9]>
<script src="http://code.jquery.com/jquery-1.10.2.js"></script>
<![endif]-->
<!--[if gte IE 9]><!-->
<script src="http://code.jquery.com/jquery-2.0.3.js"></script>
<!--<![endif]-->
<script src="js/bootstrap.js"></script>
<script src="js/csl.js" type="text/javascript">
</script>
</body>
</html>
Right then, it seems that IE had a problem with the js file. It does not like the fact I have the global 'url' variable outside of all functions. So I had to name this variable within the (document).ready(function{}). Also I had the ajaxSuccess and ajaxError functions operating on their own, they also needed to be brought within the (document).ready function, merely naming the url variable inside them individually did not work. Basically everything needs to be wrapped in one main function. this link here inspired the solution http://patrickgibson.com/news/andsuch/000202.php
$(document).ready(function(){
var url="../../index.php/cslcontrol/";
//$.ajaxSetup({ global: true });
//hide divs with the class '.views' except the one with id of 'home'
$(".views:not('#home')").hide();
//function that ensures only the div related to the selected menubar icon is dislayed
$("li a[href]").click(function(){
//storing the value of the clicked list a href
var tabVal=$(this).attr('value');
//showing a div whose div name is the same as the value of the selected list ahref
$("#"+tabVal).show();
//keeping the other divs hidden
$(".views[id!="+tabVal+"]").hide();
});
$("#home_text").load("css/history.html #home_txt");
$("#eighties_text").load("images/Eighties_seasons.html h1, p");
$("#nineties_text").load("images/Nineties_seasons.html h1, p");
//making a ajax call to fill the champions table
$.getJSON(url+"titleWin", function(data){
$.each(data, function(){
$("#senior_champions").append("<tr><td>"+ this["Season"] + "</td><td>"+ this["Winner"] + "</td><td>" + this["Runner up"] + "</td><td>"+ this["Play off"] + "</td></tr>");
});
});
//making a ajax call to fill the senior cup table
$.getJSON(url+"senCup", function(data){
$.each(data, function(){
$("#senior_cup_finals").append("<tr><td>"+ this["Season"] + "</td><td>"+ this["Winner"] + "</td><td>" + this["Score"] + "</td><td>"+ this["Runner-up"] + "</td></tr>");
});
});
$.getJSON(url+"getClub", function(data){
$.each(data, function(){
$("#club_info").append("<a class=\"name\" role=\"button\" data-toggle=\"modal\" data-target=\"#modalCSL\">"+this["Club"]+"</a>");
});
var crests = [];
$.each(data, function(){
if(this["Image"]!=""){
crests.push("<img src=\"images/"+this["Image"]+"\" alt=\""+this["Image"]+"\" title=\""+this["Club"]+"\"/>");
}
});
$("#pix1").html(crests.slice(0, 5));
$("#pix2").html(crests.slice(5, 10));
$("#pix3").html(crests.slice(10, 15));
});
$(document).ajaxSuccess(function(event,xhr,settings){
//var json="http://davestest.webuda.com/index.php/cslcontrol/";
//if(settings.url=="history.txt"){
// $("#home_text").append("<div class=\"home-images\">do</div>");
//}
if(settings.url==url+"senCup"){
$("#senior_cup_finals td:eq(26), #senior_cup_finals td:eq(30)").append("<sup> R</sup>");
$("#senior_cup_finals td:eq(34)").append("<sup> R-p</sup>");
}
if(settings.url==url+"titleWin"){
$("#champions td:eq(11)").append("<sup> R</sup>");
$("#champions td:eq(52)").append("<sup> Gr</sup>");
$("#champions td:eq(56)").append("<sup> Pr</sup>");
}
if(settings.url==url+"getClub"){
$(".name").click(function(){
var aref= $(this).text();
$(".modal-body").load("css/history.html h1:contains('"+aref+"'), h1:contains('"+aref+"')+p");
$(".modal-footer").html("<button id=\"butt\" name=\""+aref+"\" value=\""+aref+"\">"+aref+" honours</button><div id=\"dead\"></div>");
});
$("#club_info .name:last-of-type").css({"margin-right":"50%"});
}
if(settings.url=="css/history.html"){
$("#butt").click(function(){
var testing=$(this).attr('value');
var testclean=encodeURIComponent(testing);
$.getJSON(url+"getHonours?name="+testclean, function(data){
var honours=[];
$.each(data, function(){
honours.push("<table class=\"table\" id=\"honstab\"><tr><th>"+data[0]["Source"]+"</th><th>"+data[1]["Source"]+"</th><th>"+data[2]["Source"]+"</th><th>"+data[3]["Source"]+"</th><th>"+data[4]["Source"]+"</th><th>"+data[5]["Source"]+"</th><th>"+data[6]["Source"]+"</th><th>"+data[7]["Source"]+"</th><th>"+data[8]["Source"]+"</th></tr><tr><td>"+data[0]["COUNT(*)"]+"</td><td>"+data[1]["COUNT(*)"]+"</td><td>"+data[2]["COUNT(*)"]+"</td><td>"+data[3]["COUNT(*)"]+"</td><td>"+data[4]["COUNT(*)"]+"</td><td>"+data[5]["COUNT(*)"]+"</td><td>"+data[6]["COUNT(*)"]+"</td><td>"+data[7]["COUNT(*)"]+"</td><td>"+data[8]["COUNT(*)"]+"</td></tr></table>");
$("#dead").html(honours.slice(0,1));
$("#honstab td").each(function(){
if ($(this).html()=="0"){
trial=$(this).index();
$("#honstab th:eq("+trial+"), #honstab td:eq("+trial+")").remove();
if($("#honstab tr").html()==0){
$("#honstab").html("<tr><th>No Honours</th></tr></table>");
}
}
});
});
});
});
}
});
$(document).ajaxError(function(event, jqxhr, settings){
if(settings.url==url+"senCup"){
alert("not loading");
}
});
});
Try to use Knockout binding and method ko.toJS in your view model js.

Simple HTML tags to form elements - LinkedIn Profile editing

Is there any plugin that transfoms html elements (span, div) into a form ? One example is when editing LinkedIn profile which convert the section to be modified into a form.
Thanks all !
JQuery has the Wrap method, which you can use to throw the whole div / span into a form.
$('.inner').wrap('<form class="newform" action="..." method="..." />');
Found here: http://api.jquery.com/wrap/
Consider the following HTML:
<div class="container">
<div class="inner">Hello</div>
<div class="inner">Goodbye</div>
</div>
Using .wrap(), we can insert an HTML structure around the inner elements like so:
$('.inner').wrap('<div class="new" />');
The new element is created on the fly and added to the DOM. The result is a new wrapped around each matched element:
<div class="container">
<div class="new">
<div class="inner">Hello</div>
</div>
<div class="new">
<div class="inner">Goodbye</div>
</div>
</div>
The second version of this method allows us to instead specify a callback function. This callback function will be called once for every matched element; it should return a DOM element, jQuery object, or HTML snippet in which to wrap the corresponding element. For example:
$('.inner').wrap(function() {
return '<div class="' + $(this).text() + '" />';
});
This will cause each to have a class corresponding to the text it wraps:
<div class="container">
<div class="Hello">
<div class="inner">Hello</div>
</div>
<div class="Goodbye">
<div class="inner">Goodbye</div>
</div>
</div>
Examples:
Example: Wrap a new div around all of the paragraphs.
<!DOCTYPE html>
<html>
<head>
<style>
div { border: 2px solid blue; }
p { background:yellow; margin:4px; }
</style>
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
</head>
<body>
<p>Hello</p>
<p>cruel</p>
<p>World</p>
<script>$("p").wrap("<div></div>");</script>
</body>
</html>

How to make accordion should open from top to bottom?

Hi i have used an accordion method but in this it opens the div element from top left to bottom right. i don't want like that i want this one to open from top to bottom.. help me out this please??????? Here is my code
<script type="text/javascript">
jQuery(document).ready(function(){
$('#accordion .head').click(function() {
$(this).next().toggle('slow');
return false;
}).next().hide();
});
</script>
<div id="accordion">
<h3 class="head">First header</h3>
<div style="background:#f00;">
<p>First content</p>
<p>second content</p>
<p>third content</p>
<p>fourth content</p>
<p>fifth content</p>
<p>six content</p>
</div>
</div>
try this jquery code and edit what u want
(function($) {
var allPanels = $('.accordion .dd').hide();
$('.accordion .dt a').click(function() {
allPanels.slideUp();
$(this).parent().next().slideDown();
return false;
});
})(jQuery)
http://jsfiddle.net/X9sz8/

Dojo Dialog error in Zend Framework

I'm trying to create a Dojo dialog in Zend Framework but I've run into some problems. My view code looks something like this:
<script type="text/javascript" src="<?= $this->baseUrl('/js/dojo-release-1.7.2/dojo/dojo.js')?>"
data-dojo-config="async: true" dojoConfig = "parseOnLoad: true">
</script>
<script>
require(["dijit/registry", "dojo/ready", "dojo/dom", "dijit/Dialog", "dijit/form/Form"],
function(registry, ready, dom, Dialog){
ready(function() {
createDialog = function(titleText, contentText) {
var node = dojo.byId("foobar");
var myDialog = new Dialog({ title:"From Source Node" }, node);
myDialog.show();
};
});
});
</script>
<body class="claro">
<div data-dojo-type="dijit/Dialog" id="foobar" title="Foo!" style="display: none">
<p>I am some content</p>
</div>
</body>
The button code that loads the dialog looks as follows:
<button name="btnDialog" id="dialogbtn" type="button" onclick='createDialog();'>Open</button>
The first time the button is clicked the dialog opens as expected, but once the dialog is closed and the button is clicked again, the dialog doesn't open and I get the following error in the console.
Tried to register widget with id==foobar but that id is already registered.
What am I doing wrong?
Thanks
Figured it out. I think the form wasn't parsing correctly because the dojo-config was incorrect. Changed the javascript code as follows:
<script type="text/javascript" src="<?= $this->baseUrl('/js/dojo-release-1.7.2/dojo/dojo.js')?>"
data-dojo-config="async: true, parseOnLoad:true">
</script>
<script>
require(["dijit/registry", "dijit/Dialog"], function (registry)
{
createDialog = function createDialog()
{
registry.byId("foobar").show();
}
});
</script>
and the div as follows:
<body class="claro">
<div class="dijitHidden">
<div data-dojo-type="dijit.Dialog" data-dojo-props="title:'Foo!'" id="foobar">
<p>I am some content</p>
</div>
</div>
</body>
and now the dialog dijit is saved to the registry and it's working as expected