CakePhp 3.8 with Jquery autocomplete not working - jquery-ui

I'm trying to use the autocomplete jquery function to complete a field with one of two source values: ['pere', 'mele']. unfortunately it does not work.
default.ctp
<script
src="https://code.jquery.com/jquery-3.4.1.min.js"
integrity="sha256-CSXorXvZcTkaix6Yvo6HppcZGetbYMGWSFlBw8HfCJo="
crossorigin="anonymous"></script>
<script
src="https://code.jquery.com/ui/1.12.1/jquery-ui.min.js"
integrity="sha256-VazP97ZCwtekAsvgPBSUwPFKdrwD3unUfSGVYrahUqU="
crossorigin="anonymous"></script>
<link rel="stylesheet" href="https://code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<!------ Include the above in your HEAD tag ---------->
<?php echo $this->Html->script(['single']) ?>
in view file
<?php echo $this->Form->create($societa); ?>
<fieldset>
<h1>Aggiungi Società</h1>
<div class="form-group">
<div class="col-lg-10 col-lg-offset-2">
<?php echo $this->Form->control('nome_societa',['class'=>'form-control','required' => true]);?>
</div>
</div>
<div class="form-group">
<div class="col-lg-10 col-lg-offset-2">
<?php echo $this->Form->control('nome_societa_abbreviato',['class'=>'form-control','required' => true]);?>
</div>
</div>
<div class="form-group">
<div class="col-lg-10 col-lg-offset-2">
<?php echo $this->Form->control('sede',['class'=>'form-control','id'=>'naruto','required' => true]);?>
</div>
</div>
<div class="form-group">
<div class="col-lg-10 col-lg-offset-2">
<?php echo $this->Form->control('cap',['class'=>'form-control','required' => true]);?>
</div>
</div>
<div class="form-group">
<div class="col-lg-10 col-lg-offset-2">
<?php echo $this->Form->control('citta',['class'=>'form-control']);?>
</div>
</div>
<div class="form-group">
<div class="col-lg-10 col-lg-offset-2">
<?php echo $this->Form->control('pr',['class'=>'form-control']);?>
</div>
</div>
<div class="form-group">
<div class="col-lg-10 col-lg-offset-2">
<?php echo $this->Form->button(__('Salva'),['class'=>'btn btn-primary']);?>
</div>
</div>
</fieldset>
<?php echo $this->Form->end();?>
<?php echo $this->Html->link('Indietro', ['action'=>'index'], ['class'=>'btn btn-primary']) ?>
in js file single.js
$(document).ready(function(){
$("#naruto").autocomplete({
source:['pere','mele']
});
});
in console google chrome
A cookie associated with a cross-site resource at http://bootstrapcdn.com/ was set without the `SameSite` attribute. A future release of Chrome will only deliver cookies with cross-site requests if they are set with `SameSite=None` and `Secure`. You can review cookies in developer tools under Application>Storage>Cookies and see more details at https://www.chromestatus.com/feature/5088147346030592 and https://www.chromestatus.com/feature/5633521622188032.
add#:1 A cookie associated with a cross-site resource at http://forum.jquery.com/ was set without the `SameSite` attribute. A future release of Chrome will only deliver cookies with cross-site requests if they are set with `SameSite=None` and `Secure`. You can review cookies in developer tools under Application>Storage>Cookies and see more details at https://www.chromestatus.com/feature/5088147346030592 and https://www.chromestatus.com/feature/5633521622188032.
add#:1 A cookie associated with a cross-site resource at https://forum.jquery.com/ was set without the `SameSite` attribute. A future release of Chrome will only deliver cookies with cross-site requests if they are set with `SameSite=None` and `Secure`. You can review cookies in developer tools under Application>Storage>Cookies and see more details at https://www.chromestatus.com/feature/5088147346030592 and https://www.chromestatus.com/feature/5633521622188032.
add#:1 A cookie associated with a cross-site resource at http://jquery.com/ was set without the `SameSite` attribute. A future release of Chrome will only deliver cookies with cross-site requests if they are set with `SameSite=None` and `Secure`. You can review cookies in developer tools under Application>Storage>Cookies and see more details at https://www.chromestatus.com/feature/5088147346030592 and https://www.chromestatus.com/feature/5633521622188032.
unfortunately the file does not work even if the console does not give errors

OK so it works. Fixed the various Jquery UI calls. Resolved
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="Responsive sidebar template with sliding effect and dropdown menu based on bootstrap 3">
<title>Calciotel</title>
<link href="https://use.fontawesome.com/releases/v5.0.6/css/all.css" rel="stylesheet">
<link href="https://stackpath.bootstrapcdn.com/bootswatch/4.3.1/litera/bootstrap.min.css" rel="stylesheet" id="bootstrap-css">
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<?php
echo $this->Html->css(['jquery-ui.theme.min','jquery-ui.min','prova']);
echo $this->Html->script(['bootstrap.min','jquery-3.4.1.min','jquery-ui.min','prova','single','popper.min.js']);
echo $this->Html->meta('icon');
echo $this->fetch('meta');
echo $this->fetch('css');
echo $this->fetch('script');
echo $this->Html->charset();
?>

Related

Page transitions in default mode in jquery mobile

I am trying to execute a simple jquery mobile code. I just linked two pages. But everytime I am switching from one page to another, it is happening in default mode.Even after mentioning data-transition = 'pop'..
<!DOCTYPE html>
<html>
<head>
<title>This is my first jquery mobile programme</title>
<meta name="viewport" content="width=device-width, initialscale=1">
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.4.2/jquery.mobile.structure-1.4.2.min.css" />
<script src="http://code.jquery.com/jquery-1.11.0.js"></script>
<script src="http://code.jquery.com/mobile/1.4.2/jquery.mobile-1.4.2.min.js"></script>
</head>
<body>
<div data-role = "page" id="first">
<div data-role = "header" >
<h1>hello world !!</h1>
</div>
<div data-role = "content">
<p>This is the content part</p>
<p><a href ="#second" data-tansition = "pop" > Go to second page </a></p>
</div>
<div data-role ="footer">
<h4>Footer</h4>
</div>
</div>
<div data-role = "page" id="second">
<div data-role ="header">
<h1>hello Praveen !!</h1>
</div>
<div data-role ="content">
<p> this is the second page</p>
<p><a href =#first> Go to first page </a></p>
</div>
<div data-role = "footer">
<h4>footer</h4>
</div>
</div>
You simply have a typo in your markup.
Change
data-tansition="pop"
to
data-transition="pop"

Strange cflocation behavior: redirecting to page but not updating url

I have a basic mobile login page in ColdFusion that allows the user to enter a username and password and log in. On successful login, the page redirects to the home page using a cflocation. However, while the page redirects successfully to the home page, it still displays the login page URL in the location bar. We have used cflocation many times throughout our web application and I have never come across this behavior before and can't figure out what could be causing it.
The gist of the page code:
<cfparam name="invalidLogin" default="false">
<cfif cgi.REQUEST_METHOD EQ "POST" AND isDefined("form.email") AND isDefined("form.password") and len(trim(form.email)) and len(trim(form.password))>
<!--- call the login method --->
<cfinvoke component="login" method="userlogin" returnvariable="userData">
<cfinvokeargument name="userName" value="#form.email#">
<cfinvokeargument name="password" value="#form.password#">
</cfinvoke>
<cfif userData.isLoggedIn>
<cflocation url="index.cfm" addtoken="no">
</cfif>
<cfset invalidLogin = true />
</cfif>
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Log In</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="css/jquery.mobile.structure-1.3.2.css" rel="stylesheet" type="text/css" />
<link href="css/jquery.mobile-1.3.2.css" rel="stylesheet" type="text/css" />
<link href="css/common.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="js/jquery-1.9.1.min.js"></script>
<script type="text/javascript" src="js/jquery.mobile-1.3.2.js"></script>
<script type="text/javascript" src="js/common.js"></script>
</head>
<body>
<div data-role="page" class="bg-color">
<div class="container">
<div data-role="content">
<div class="article">
<div class="logoDiv">
<img src="img/companyLogo.png" />
</div>
</div>
<form action="" method="post" name="frmLogin" id="frmLogin" class="margin-top" data-transition="slide">
<div>
<input type="text" name="email" id="email" placeholder="Username">
<input type="password" name="password" id="password" placeholder="Password">
</div>
<cfif invalidLogin><div>Invalid Login</div></cfif>
<div>
<input type="submit" value="Log In" data-theme="b" />
</div>
</form>
</div>
</div>
</div>
</body>
</html>
To prevent jQuery Mobile from handling forms with redirect via Ajax, you need to turn Ajax Navigation off and handle the request through HTTP.
To do so, add data-ajax="false" attribute to form tag. This will stop Ajax Navigation on the form only.
Note that you will lose transition when moving for current form page to new page as Ajax is turned off, so data-transition="slide" will have no effect.
<form action="" data-ajax="false" method="post" name="frmLogin" id="frmLogin">

Zend Framework - Controller - HeadScript - Not Loading After `composer update`

I am quite new to Zend Framework (2). I have been developing a mini ERP as a project and every thing seemed to be good.
But this morning, I wanted to install PHPUnit, I updated the composer.json file and ran composer install but it saind nothing to install. Then after some brief searches, I noted that I should be running composer update instead. It did update Zend Framework to 2.2.0 and some others. Zend used to be 2.0.8.
I ran the applicaiton, it all looked good, until my partner complained a demo failed.
I diagnosed the problem, which was caused by not loading JavaScript files. The required JavaScripts for the view were given through the controller as follows.
public function viewContactAction(){
// Get the user id from url
$id = $this->params()->fromRoute('id');
$this->headScript = new HeadScript();
$this->headScript->appendFile('../../js/pages/lib/contact.view.js');
$this->headScript->appendFile('../../js/packages/json-populate/dist/jquery.jsonPopulate.min.js');
$view = new ViewModel(array('title' => 'Contact View', 'contact_id' => $id));
$view->setTemplate('contacts/contacts/contact');
return $view;
//die("User View for $id");
}
Then I looked in to the Layout file under the Application model. It seemed to be using some thing different. And I updated it as follows.
public function viewContactAction(){
// Get the user id from url
$id = $this->params()->fromRoute('id');
//$this->headScript = new HeadScript();
$this->headScript()->appendFile('../../js/pages/lib/contact.view.js');
$this->headScript()->appendFile('../../js/packages/json-populate/dist/jquery.jsonPopulate.min.js');
$view = new ViewModel(array('title' => 'Contact View', 'contact_id' => $id));
$view->setTemplate('contacts/contacts/contact');
return $view;
//die("User View for $id");
}
Thinking it would be some thing like a file-not-found issue, I changed the file paths as if it was in the public folder /js/pages/lib/contact.view.js, but still the files don't show up.
Is using HeadScript in the controller no longer supported? Or has the way changed? Thanks in advance.
ok, this is my layout file. I don't remember making any changes to it except add some js.
<?php echo $this->doctype(); ?>
<html lang="en">
<head>
<meta charset="utf-8">
<?php echo $this->headTitle('ZF2 '. $this->translate('Skeleton Application'))->setSeparator(' - ')->setAutoEscape(false) ?>
<?php echo $this->headMeta()->appendName('viewport', 'width=device-width, initial-scale=1.0') ?>
<!-- Le styles -->
<?php echo $this->headLink(array('rel' => 'shortcut icon', 'type' => 'image/vnd.microsoft.icon', 'href' => $this->basePath() . '/images/favicon.ico'))
->prependStylesheet($this->basePath() . '/css/bootstrap-responsive.min.css')
->prependStylesheet($this->basePath() . '/css/style.css')
->prependStylesheet($this->basePath() . '/css/bootstrap.min.css') ?>
<!-- Scripts -->
<?php echo $this->headScript()->prependFile($this->basePath() . '/js/html5.js', 'text/javascript', array('conditional' => 'lt IE 9',))
->prependFile($this->basePath() . '/js/bootstrap.min.js')
->prependFile($this->basePath() . '/js/jquery.min.js')
->appendFile($this->basePath() . '/js/jquery.konnections.tableDefinition.js')
->appendFile($this->basePath() . '/js/jquery.konnections.appendTemplateFromJSON.js'); ?>
<?php //echo $this->headScript; ?>
</head>
<body>
<div class="navbar navbar-inverse navbar-fixed-top">
<div class="navbar-inner">
<div class="container">
<a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</a>
<a class="brand" href="<?php echo $this->url('home') ?>"><?php echo $this->translate('Skeleton Application') ?></a>
<div class="nav-collapse collapse">
<ul class="nav">
<li class="active"><?php echo $this->translate('Home') ?></li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">
<?php echo $this->translate('Contacts'); ?>
</a>
<ul class="dropdown-menu">
<li><a href='contacts'>Contact Table</a></li>
<li><a href='contacts/add-contact'>Add New Contact</a></li>
</ul>
</li>
</ul>
</div><!--/.nav-collapse -->
</div>
</div>
</div>
<div class="container">
<?php echo $this->content; ?>
<hr>
<footer>
<p>© 2005 - 2012 by Zend Technologies Ltd. <?php echo $this->translate('All rights reserved.') ?></p>
</footer>
</div> <!-- /container -->
<?php echo $this->inlineScript() ?>
</body>
</html>
The Generated source looks like this (page is kinda very long, so only the header i sincluded).
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>ZF2 Skeleton Application</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- Le styles -->
<link href="/css/bootstrap.min.css" media="screen" rel="stylesheet" type="text/css">
<link href="/css/style.css" media="screen" rel="stylesheet" type="text/css">
<link href="/css/bootstrap-responsive.min.css" media="screen" rel="stylesheet" type="text/css">
<link href="/images/favicon.ico" rel="shortcut icon" type="image/vnd.microsoft.icon">
<!-- Scripts -->
<script type="text/javascript" src="/js/jquery.min.js"></script>
<script type="text/javascript" src="/js/bootstrap.min.js"></script>
<!--[if lt IE 9]><script type="text/javascript" src="/js/html5.js"></script><![endif]-->
<script type="text/javascript" src="/js/jquery.konnections.tableDefinition.js"></script>
<script type="text/javascript" src="/js/jquery.konnections.appendTemplateFromJSON.js"></script> </head>
You're trying to use a ViewHelper at the ControllerLevel. This isn't possible like this. The shorthand-functions like $this->blubb() inside the Controller are called ControllerPlugins. You can get a list of all the ControllerPlugins right here at Zend\Mvc\Controller\Plugin\*.
When you want to access a ViewHelper at the Controller-Level you need to gain access to the ViewHelperManager. This is done via the ServiceManager in the following manner:
$vhm = $this->getServiceLocator()->get('viewhelpermanager');
$headScript = $vhm->get('headscript');
$headScript->appendFile(/** ... */);
Didn't test it as it wasn't ever needed but it should definitely be working. Let me know in case it doesn't work ;)
I modified the above script.
This is the verified working code.
$vhm = $this->getServiceLocator()->get('ViewHelperManager');
$headScript = $vhm->get('headscript');
$headScript->appendFile( $url );

jQuery mobile dialog not working with new page

I have a site built on jQuery Mobile and am trying to get our Terms of Service to open in a dialog.
TOS page is a full page itself (separate URL) and when I link with the dialog reference it simply opens as a new page.
My footer is
<div data-role="footer" data-theme="<?php echo $dataTheme ?>">
<div data-role="navbar">
<ul>
<li>Home</li>
<li><a rel="external" href="http://www.trackmaster.com">Full Site</a></li>
<li>Terms</li>
<li>My Account</li>
</ul>
</div>
</div>
and my tos.php page is (content stripped for convenience)
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="author" content="AXCIS Information Network">
<title>TrackMaster Terms of Service</title>
<link rel="stylesheet" href="http://mobiletest.trackmaster.com/styles/mobile/themes/TrackMasterMobile.min.css" />
<link rel="stylesheet" href="http://mobiletest.trackmaster.com/styles/mobile/jquery.mobile.structure-1.2.0.min.css" />
<script src="http://mobiletest.trackmaster.com/javascript/frameworks/jquery-current.min.js"></script>
<link rel="stylesheet" href="http://mobiletest.trackmaster.com/styles/mobile/mobileStyle.css" />
<!-- Make sure there is a back button on each page -->
<script type="text/javascript">
$(document).bind("mobileinit", function(){
$.mobile.ajaxEnabled = false;
$.mobile.page.prototype.options.addBackBtn= true;
});
</script>
<script src="http://mobiletest.trackmaster.com/javascript/frameworks/jquery.mobile-current.min.js"></script>
</head>
<body>
<div data-role="page" data-theme="a" id="main">
<div data-role="header">
<h1 class="headerLink"><span class="tmFirst">Track</span><span class="tmSecond">Master</span> </h1>
Home
</div>
<div data-role="content" data-theme="a">
<div data-role="content" class="informationText">
Blah, Blah, Blah
</div>
</div> <!-- this one closes out the content div set in the section header template -->
<div data-role="footer" data-theme="a">
<div data-role="navbar">
<ul>
<li>Home</li>
<li><a rel="external" href="http://www.trackmaster.com">Full Site</a></li>
<li>Terms</li>
<li>My Account</li>
</ul>
</div>
<h5 class="copyrightText">© 2013 Axcis Information Network, Inc.</h5>
<div class="ads">
<script type="text/javascript"><!--
google_ad_client = "ca-pub-7303976721498796";
/* Mobile Bottom */
google_ad_slot = "5684536575";
google_ad_width = 320;
google_ad_height = 50;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
</div>
</div>
</div> <!-- this one closes out the page div set in the header template -->
</body>
</html>
I have tried changing the data role of the TOS page to a dialog but that made no difference.
Am I not understanding the way dialog links can be used (from the docs I thought I could open one from any URL simply by defining the link as a dialog)
Site itself is http://mobiletest.trackmaster.com and it is the Terms link in the footer I am trying to get as a dialog (I don't want to include the content on every page, only when the user asks for it)
Any help appreciated (even pointing out the dumb things I am missing)
You are either missing a <div> or they don't match up; you've got two "content" divs.
EDIT: It's probably OK to have one within another, just noting that the <div data-role="page"> is never closed. Don't know if that makes any difference.
Found the issue.
The line in the header
$.mobile.ajaxEnabled = false;
I commented it out and the dialog link works as expected.
was the problem, I am testing it to see what else gets broken when I pull it out :-).
Data role for the TOS page is NOT relevant as loading it as a dialog automatically assigns the dialog data role

Web page displaying as XML in Opera

Opera is displaying my new site as XML and I can't for the life of me figure out why.
Here's what firebug has to say
Server ASP.NET Development Server/10.0.0.0
Date Mon, 08 Nov 2010 22:58:32 GMT
X-AspNet-Version 4.0.30319
X-AspNetMvc-Version 2.0
Content-Encoding gzip
Cache-Control private
Content-Type text/html; charset=utf-8
Content-Length 1835
Connection Close
Here's what W3C has to say
Line 3, column 6: application/xhtml+xml is not an appropriate Content-Type for a document whose root element is not in a namespace.
<html>
Line 3, column 6: Unnamespaced element html not allowed in this context. (Suppressing further errors from this subtree.)
<html>
Here's the markup
<!DOCTYPE html>
<html>
<head>
<title>What's happening around you right now! - My App</title>
<meta content="no" http-equiv="imagetoolbar" />
<link rel="search" type="application/opensearchdescription+xml" title="My App" href="/assets/xml/opensearch.xml" />
<link rel="stylesheet" type="text/css" href="/MYREALLYCOOLAPP/Extras/siteMaster.Css/1" />
</head>
<body>
<div class="page">
<div id="header">
<div id="title">
<div id="urban-now-logo">
<span>My App</span>
</div>
</div>
<div id="logindisplay">
<span id="logindisplaywrapper">log in | <a href="/MYREALLYCOOLAPP/modalwindow/selectregion"
title="Change Region" class="RegionWindow">Calgary</a> | about | faq
<span style="padding-left: 20px;"></span>
<form action="/MYREALLYCOOLAPP/search" id="searchForm" method="get">
<input id="search-text" name="q" tabindex="1" type="text" maxlength="80" size="28" placeholder="search..." />
</form>
</span>
</div>
<div id="menucontainer">
<div class="floatleft">
<ul class="menu">
<li><a class="youarehere" href="/MYREALLYCOOLAPP/">Now</a></li>
<li>Coming</li>
<li>Hot</li>
<li>Tags</li>
<li>Users</li>
</ul>
</div>
<div class="floatright">
<ul class="menu">
<li>Add Event</li>
</ul>
</div>
</div>
</div>
<div class="clear">
</div>
<div id="main">
<h2>What's Happening Within The Next 24 Hours!</h2>
<hr />
<div id="innermain">
<div class="twocolumn-left">
<div id='bingMap' class="largeMap">
<noscript>
<img src="http://developer.multimap.com/API/map/1.2/OA10091719904371779?zoomFactor=11&width=550&height=400&lat_1=51.18468&lon_1=-114.497999&lat_2=51.169858&lon_2=-114.32549&lat_3=51.083277&lon_3=-114.203964&lat_4=51.063097&lon_4=-114.092031&lat_5=50.939664&lon_5=-113.973568" />
</noscript>
</div>
</div>
<div class="twocolumn-right">
</div>
</div>
<div id="footer">
<ul id="footernavigation">
<li>© 2010 - My App - All Rights Reserved</li>
<li><span class="colorgreen increasesize-140">■</span> about | <span class="colorgreen increasesize-140">
■</span> faq | <span class="colorgreen increasesize-140">■</span> <a href="/MYREALLYCOOLAPP/about/advertise">
advertise</a> | <span class="colorgreen increasesize-140">■</span> legal</li>
</ul>
</div>
</div>
</div>
<script type="text/javascript" src="http://ajax.microsoft.com/ajax/jquery/jquery-1.4.2.min.js"></script>
<script type="text/javascript" src="http://ecn.dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=6.3"></script>
<script type="text/javascript" src="/MYREALLYCOOLAPP/Extras/MYREALLYCOOLAPP.js/1"></script>
<script type="text/javascript">
var zoomLevel = 10
var json_object = [{ "lat": 51.063097, "lon": -114.092031, "title": "Jubilee Auditorium", "desc": "Some great concerts go down here"}];
</script>
<script type="text/javascript" src="/MYREALLYCOOLAPP/Extras/bingmaps.js/1"></script>
</body>
</html>
Basically, when I launch the website in Opera, the top says
This document had no style information.
and then all of my markup is displayed (like xml).
It looks like your server is sending the file as text/html to Firefox, but application/xhtml+xml to Opera.
Opera (10.63) has a firebug-like interface you can check this with. Right click on a page to bring up the context menu, select "Inspect Element". Select the "Network" tab and expand the relevant request line. Then open either "Headers" or "Raw" and it will show you the content-type used to send the page to Opera.
To allow Opera to process the page correctly as application/xhtml+xml, add
xmlns="http://www.w3.org/1999/xhtml"
as an attribute to the html element as LukeH says.
Doesn't your DOCTYPE need to specify the appropriate DTD etc? For example:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
And/or do you need to specify a namespace for your <html> element? For example:
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

Resources