onClick event won't work until page is reloaded - ruby

The following code snippet which includes an onClick event will
not work until I click reload on both the simulator and the phone.
The code is in an .erb file in an app model folder.
<section id="page1" data-role="page">
<header data-role="header">
<h1>CSS 3 Animations</h1>
</header>
<div data-role="content" class="content">
<p class="show-menu" onclick="ToggleText()">(Show/Hide) Menu</p>
<div class="sliding-menu slide out">Menu</div>
</div>
</section>
<script type="text/javascript">
function ToggleText() {
$(".sliding-menu").toggleClass("reverse out in");
}
</script>
I'm using rhomobile 3.2.1 with. Can someone explain why and what to do to
fix it?

Would something like this work?
http://jsfiddle.net/aJshm/3/
JS
$('.toggle-menu').click(function() {
$(".sliding-menu").toggleClass("reverse out in");
});
HTML
<section id="page1" data-role="page">
<header data-role="header">
<h1>CSS 3 Animations</h1>
</header>
<div data-role="content" class="content">
<p class="toggle-menu">(Show/Hide) Menu</p>
<div class="sliding-menu slide out">Menu</div>
</div>
</section>

Just a guess, try defining the function before it is invoked?

Related

Why embedding an iframe pushes down a sidebar?

I am building a simple static website. I am using Spring Boot, Thymeleaf Layout Dailect and Bootstrap 4. In my layout.html I have a row in which I have a content and a sidebar. I have 2 photos in my sidebar, in all of views they appear on the right side. However when I try to embed an iframe with a google map or with a facebook page the sidebar gets pushed down. I tried a few different things like changing the size of iframe to minimum etc. but I am unable to keep my sidebar on the right side. Please can anyone suggest a solution?
Below is my layout.html:
<body>
<div class="container-fluid" th:replace="fragments/navigation :: navigation"></div>
<div class="container-fluid" id="mainContent">
<div class="row">
<div class="col-md-8">
<div layout:fragment="content"></div>
</div>
<div class="col-md-4">
<div th:replace="fragments/sidebar :: sidebar"></div>
</div>
</div>
</div>
<div class="container-fluid" th:replace="fragments/footer :: footer"></div>
Below is my sidebar.html:
<body>
<div th:fragment="sidebar">
<div class="panel-group">
<div class="panel panel-default">
<div class="panel-body">
<img src="/img/ai-ki-do.png" alt="Logo" style="width: 330px;"></img>
</div>
</div>
<div class="panel panel-default">
<div class="panel-body">
<img src="/img/ueshiba-laughter.jpg" alt="Logo"
style="width: 330px;" ></img>
</div>
</div>
</div>
</div>
</body>
Below is my content:
<body>
<div layout:fragment="content">
<p>Thank you for your interest in Seishinkan. Please get in touch via our Facebook page. We look forward to hearing from you.</p>
<div class="embed-responsive embed-responsive-16by9">
<iframe class="embed-responsive-item" src="https://www.facebook.com/plugins/page.php?href=https%3A%2F%2Fwww.facebook.com%2FSeishinkan-Aikido-Dojo-389984175129276%2F&tabs=timeline&width=340&height=500&small_header=false&adapt_container_width=true&hide_cover=false&show_facepile=true&appId" data-adapt-container-width="true"></iframe>
</div>
</body>
Normal sidebar's behaviour - a white picture 'Ai Ki Do' and a dark picture on the right side :
The sidebar pushed down after embedding the iframe:
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
<div class="row">
<iframe src="https://www.w3schools.com">
<p>Your browser does not support iframes.</p>
</iframe>
<div>
another one
</div>
</div>
For some reason when I remove the col classes from the divs and keep them in a row, the two pieces don't go below each other
Have you tried inspecting the element and editing your css classes in the browser while in developer mode?
I had the same problem before and all I did was mess around with the code in the console until it eventually moved the way I wanted it to.
Placing a new row and column within:
<div layout:fragment="content"></div>
worked for me.
<div layout:fragment="content">
<div class="row">
<div id="dojo-page" class="col-md-12">
<div id="fb-frame" class="embed-responsive embed-responsive-16by9">
<iframe class="embed-responsive-item" width="600" height="450"
frameborder="0" style="border: 0"
src="path-for-google-map-location"
allowfullscreen></iframe>
</div>
</div>
</div>

AJAX loading img

I am new to AJAX/Jquery, what is the best way to put a loading img while the page is is still on load ?
here is my code:
<div class="container">
<div class="row">
<div class="col-lg-12">
<button class="btn btn-info btn-lg">Load More Page...</button>
</div>
</div>
</div>
<script type="text/javascript">
$(document).ready(function(){
$("button").click(function(){
$("#box").load("page2.php");
});
});
</script>
Please check below link
There is example
How can I create a "Please Wait, Loading..." animation using jQuery?
You can simply use ajax- methods like ajaxStart, ajaxStop
Javascript code:
$(document).ready(function(){
$(document).ajaxStop(function(){
$('#loadingIndicator').hide(500);
});
$( document ).ajaxStart(function() {
$('#loadingIndicator').show();
});
}
HTML code:
<div id="loadingIndicator" style="display:none;z-index:100;">
<img src="loading-big.gif" alt="" />
</div>

Fancy box will not work

here is my codepen:
`
<script type="text/javascript">
$(document).ready(function() {
$(".fancybox").fancybox();
});
</script>
<div class="container">
<div class="row">
<div class="col-sm-9" id="mainContent">
<a class="fancybox" rel="group" href="img/1.jpg"><img src="img/1a.jpg" alt="" /></a>
<a class="fancybox" rel="group" href="img/me2.jpg"><img src="img/me3.jpg" alt="" /></a>
</div>
</div>
</div>
`
http://codepen.io/anon/pen/gMbmzZ
I can't get this fancy box to work for the life of me. I have checked the file path for the css and the javascript and those should be good. I have also made sure to import jquery into my html file.
no matter what i do i can't get it to work. any help is appreicated.

kendo ui mobile events in templates not fireing

I using this approach for my new app.
http://blogs.telerik.com/blogs/14-03-27/structuring-hybrid-mobile-applications
But I running in a problem with click events when I calling templates in my view.
Everything else like data binding init kendo widgets works fine.
What I missing here?
<div data-role="view" id="home" data-model="APP.home.model" data-init="APP.home.events.init" data-after-show="APP.home.events.afterShow" style="display: none;">
<header data-role="header">
<div data-role="navbar">
<a data-role="button" data-rel="drawer" href="#categories" data-icon="drawer-button" data-align="left"></a>
<span data-role="view-title"></span>
<div data-role="button" data-bind="click: hello" data-align="right" data-icon="compose">a</div>
</div>
</header>
<div>TEST me</div>
<div data-role="button" data-bind="click: hello" data-align="right" data-icon="compose">a</div>
<div id="testMe">
</div>
<div id="home-grid" class="grid home-grid"></div>
</div>
<script>
var events = {
init: function (e) {
navbar = e.view.header.find('.km-navbar').data('kendoMobileNavBar');
var template = kendo.template($("#testMe_tmp").html());
$("#testMe").html(template({}));
kendo.mobile.init($("#testMe"));
},
afterShow: function (e) {
navbar.title("b");
}
};
</script>
Thanks in advance
T.S
I found a solution
after
kendo.mobile.init($("#testMe"));
add this
kendo.bind($("#content"),model);
I don't understand why then I never find a sample source need this.
T.S

KendoUI tabstrip navigates to blank page

I'm using a custom tabstrip that I took from the KendoUI page and adapted for my application.\
It has 3 tabs (home, startOfDay and stops). Each tab goes to an HTML page.
The problem is this, I can navigate from Home to one of the other tabs without a problem, but after that if I try navigate to another tab it just goes to a blank page.
Here's the my layout code.
<section data-role="layout" data-id="default">
<header data-role="header">
<div data-role="navbar">FnF Driver Application</div>
</header>
<!--View content will render here-->
<footer data-role="footer">
<div data-role="tabstrip" id="custom-tabstrip">
<a data-icon="home" href="home.html">Home</a>
<a data-icon="globe" href="startOfDay.html">Start Of Day</a>
<a data-icon="toprated" href="stops.html">Stops</a>
</div>
</footer>
</section>
each page is contained in a div that looks like this...
<body>
<div id="home/startOfDay/stops" data-role="view" data-layout="default">
~Content goes here~
</div>
</body>
Any help would be greatly appreciated.
Thanks!!!
Try removing the <body> tags from your views? I think when Kendo UI Mobile reads in a remote view it injects it into the page DOM, and having another <body> tag might be messing it up.
I read somewhere that a layout has to have at least one view defined to work properly, even if it is a blank view. Try putting in a blank view.
<section data-role="layout" data-id="default">
<header data-role="header">
<div data-role="navbar">FnF Driver Application</div>
</header>
<!--View content will render here-->
<div data-role="view"></div>
<footer data-role="footer">
<div data-role="tabstrip" id="custom-tabstrip">
<a data-icon="home" href="home.html">Home</a>
<a data-icon="globe" href="startOfDay.html">Start Of Day</a>
<a data-icon="toprated" href="stops.html">Stops</a>
</div>
</footer>
</section>

Resources