Hide Submit Button on Success Message - ajax

Please can some one point me in the right direction with this code.
When my form has been submitted a message is displayed however at the moment the Submit Button is still present.
I want to remove/hide the submit button once the form has been successfully submitted and the Success Message is being displayed.
I have looked around for answers on stack-overflow but so far everything I have tried has not worked.
Im sure I need to add something like this:
$('#sky-form button[type="submit"]').hide();
However I think maybe there is something already in the code that is stopping this from happening.
Here is my submit and message part of my form:
<button type="submit" button class="border-button">NEXT</button>
<div class="message">
<i class="fa fa-check"></i>
<p>Thanks for your order!<br>We'll contact you very soon.</p>
</form>
And here is the ajax:
submitHandler: function(form)
{
$(form).ajaxSubmit(
{
beforeSend: function()
{
$('#sky-form button[type="submit"]').addClass('button-uploading').attr('disabled', true);},
uploadProgress: function(event, position, total, percentComplete)
{
$("#sky-form .progress").text(percentComplete + '%');
},
success: function()
{
$("#sky-form").addClass('submited');
$('#sky-form button[type="submit"]').removeClass('button-uploading').attr('disabled', false);
}
});
},
Thanks so much to anyone that can help with this.
FULL CODE:
<form action="demo-order-process.php" method="post" enctype="multipart/form-data" id="sky-form" class="sky-form">
<fieldset>
<div class="row">
<div class="col-md-4" align="left">
<label class="input">
<input type="text" name="home_address" placeholder="Home Address">
<b class="tooltip tooltip-bottom-left">Enter your home address</b>
</label>
</div>
<div class="col-md-4" align="left">
<label class="input">
<input type="text" name="biz_address" placeholder="Biz Address">
<b class="tooltip tooltip-bottom-left">Enter your biz address</b>
</label>
</div>
</div><!-- END OF ROW DIV -->
</fieldset>
<!-- FORM ONE DATA -->
<input type="hidden" name="name"
value="<?php echo $_POST['name']; ?>">
<input type="hidden" name="email"
value="<?php echo $_POST['email']; ?>">
<!-- END OF FORM TWO DATA -->
<!-- FORM TWO DATA -->
<input type="hidden" name="mobile"
value="<?php echo $_POST['mobile']; ?>">
<input type="hidden" name="home"
value="<?php echo $_POST['home']; ?>">
<!-- END OF FORM TWO DATA -->
<div class="row">
<div class="col-md-4" align="left">
<button type="submit" button class="border-button">NEXT</button>
</div>
</div><!-- END OF ROW DIV -->
<div class="message">
<i class="fa fa-check"></i>
<p>Thanks for your order!<br>We'll contact you very soon.</p>
</div>
</form>
</div>
<!-- START OF JS VALIDATION -->
<script type="text/javascript">
$(function()
{
$("#sky-form").validate(
{
rules:
{
home_address:
{
required: true
},
biz_address:
{
required: true
},
messages:
{
home_address:
{
required: 'Please enter your home address'
},
biz_address:
{
required: 'Please enter your business address'
},
},
// Ajax form submition
submitHandler: function(form)
{
$(form).ajaxSubmit(
{
beforeSend: function()
{
$('#sky-form button[type="submit"]').addClass('button-uploading').attr('disabled', true);
},
uploadProgress: function(event, position, total, percentComplete)
{
$("#sky-form .progress").text(percentComplete + '%');
},
success: function()
{
$("#sky-form").addClass('submited');
$('#sky-form button[type="submit"]').removeClass('button-uploading').attr('disabled', false);
}
});
},
errorPlacement: function(error, element)
{
error.insertAfter(element.parent());
}
});
});
</script>
<!-- END OF JS VALIDATION -->
JQuery Librarys:
`
<!-- fort forms -->
<script src="../form/jquery.min.js"></script>
<script src="../form/jquery-ui.min.js"></script>
<script src="../form/jquery.form.min.js"></script>
<script src="../form/jquery.validate.min.js"></script>
<!-- for page finctions -->
<!-- PROBLEM FILE = <script type="text/javascript" src="../js/jquery-1.11.0.min.js"></script>-->
<script type="text/javascript" src="../js/jquery-migrate-1.2.1.min.js"></script>
<script type="text/javascript" src="../js/bootstrap.min.js"></script>
<script type="text/javascript" src="../js/jquery.mb.YTPlayer.min.js"></script>
<script type="text/javascript" src="../js/jquery.flexslider-min.js"></script>
<script type="text/javascript" src="../js/perfect-scrollbar.js"></script>
<script type="text/javascript" src="../js/plugins.js"></script>
<script type="text/javascript" src="../js/main.js"></script>`

I just tried this code and seems to be working.
If it did not work please check the error you are getting in console.
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<script src="http://jqueryvalidation.org/files/dist/jquery.validate.js"></script>
<script src="http://malsup.github.com/jquery.form.js"></script>
<form action="demo-order-process.php" method="post" enctype="multipart/form-data" id="sky-form" class="sky-form">
<fieldset>
<div class="row">
<div class="col-md-4" align="left">
<label class="input">
<input type="text" name="home_address" placeholder="Home Address">
<b class="tooltip tooltip-bottom-left">Enter your home address</b>
</label>
</div>
<div class="col-md-4" align="left">
<label class="input">
<input type="text" name="biz_address" placeholder="Biz Address">
<b class="tooltip tooltip-bottom-left">Enter your biz address</b>
</label>
</div>
</div><!-- END OF ROW DIV -->
</fieldset>
<!-- FORM ONE DATA -->
<input type="hidden" name="name" value="<?php echo $_POST['name']; ?>">
<input type="hidden" name="email" value="<?php echo $_POST['email']; ?>">
<!-- END OF FORM TWO DATA -->
<!-- FORM TWO DATA -->
<input type="hidden" name="mobile" value="<?php echo $_POST['mobile']; ?>">
<input type="hidden" name="home" value="<?php echo $_POST['home']; ?>">
<!-- END OF FORM TWO DATA -->
<div class="row">
<div class="col-md-4" align="left">
<button type="submit" button class="border-button">NEXT</button>
</div>
</div><!-- END OF ROW DIV -->
<div class="message">
<i class="fa fa-check"></i>
<p>Thanks for your order!<br>We'll contact you very soon.</p>
</div>
</form>
<!-- START OF JS VALIDATION -->
<script type="text/javascript">
$(function()
{
$("#sky-form").validate({
rules:
{
home_address:
{
required: true
},
biz_address:
{
required: true
}
},
messages:
{
home_address:
{
required: 'Please enter your home address'
},
biz_address:
{
required: 'Please enter your business address'
},
},
// Ajax form submition
submitHandler: function(form) {
$(form).ajaxSubmit(
{
beforeSend: function()
{
$('#sky-form button[type="submit"]').addClass('button-uploading').attr('disabled', true);
},
uploadProgress: function(event, position, total, percentComplete)
{
$("#sky-form .progress").text(percentComplete + '%');
},
success: function()
{
$("#sky-form").addClass('submited');
$('#sky-form button[type="submit"]').removeClass('button-uploading').attr('disabled', false);
$('#sky-form button[type="submit"]').hide();
}
});
},
errorPlacement: function(error, element)
{
error.insertAfter(element.parent());
}
});
});
</script>
<!-- END OF JS VALIDATION -->

Related

How to keep white spaces in the beginning of string from json response rendered by Kendo DataSource?

DataSource gets json response data:
categoriesDS = new kendo.data.DataSource({
transport: {
read: {
url: "{{ path('get_json_categories') }}",
dataType: "json"
}
}
});
with white spaces:
{"categoryId":33,"parentId":32,"name":" [ ] p1"}
but rendering it without white spaces. How to change this behaviour?
edit: I need whitespaces in select options input. Below is my template script
<script id="popup_editor" type="text/x-kendo-template">
<form method="post" action="{{ path('updatedoc') }}" enctype="multipart/form-data">
<div class="k-edit-label">
<label for="documentFile">Plik</label>
</div>
<div data-container-for="documentFile" class="k-edit-field">
<input name="files" id="files" type="file" aria-label="files"/>
</div>
<input name="documentId" id="documentId" type="text" data-bind="value:documentId" style="display: none;"/>
<div class="k-edit-label">
<label for="documentDateAdd">Data Dodania</label>
</div>
<div class="k-edit-field">
<input type="text" class="k-input k-textbox k-state-disabled" name="documentDateAdd"
data-bind="value:documentDateAdd" disabled>
</div>
<div class="k-edit-label">
<label for="documentDesc">Opis</label>
</div>
<div data-container-for="documentDesc" class="k-edit-field">
<textarea name="documentDesc" class="k-textbox" data-bind="value:documentDesc"></textarea>
</div>
<div class="k-edit-label">
<label for="user">Twórca</label>
</div>
<div data-container-for="user" class="k-edit-field">
<input type="text" class="k-input k-textbox k-state-disabled" name="user" data-bind="value:user"
disabled>
</div>
<!-- dropdownlist-->
<div class="k-edit-label">
<label for="FacultyRankId">Kategoria</label>
</div>
<!-- dropdownlist editor for field: "FacultyRankId" -->
<div class="k-edit-field" id="categoriesDiv">
<input id="categoriesInput" name="categoryId"
{# tu wskazuję z którą wartością z data-source wiązać ten input tj z czym synchronizować, czyli
zmiany w inpucie na które pole ma wpływać z dataSource#}
data-bind="value:categoryId"
data-value-field="categoryId"
{#to co jest wyświetlane w dropdown#}
data-text-field="name"
data-source="categoriesDS"
data-role="dropdownlist"
data-value-primitive="true"
/>
</div>
<script type="text/javascript">
$('.k-edit-buttons:eq(1)').hide();
$("span.k-dropdown-wrap > span.k-input").each(function() {
console.log($(this).text());
var text = $(this).text().replace('PODKATEGORIA666, ', '. .');
$(this).text(text);
});
<\/script>
<div class="k-edit-buttons k-state-default">
<button type="submit" class="k-button k-primary"> Aktualizuj </button>
</div>
</form>
</script>
and style selector that didn't work:
<style>
input#categoriesInput { white-space: pre; }
</style>
(It looks like your post is mostly bar code; please add some more details.It looks like your post is mostly code; )
Try setting white-space style to pre and depending on the widget that you want to use it you will have to use different selectors.
Following an example for showing it in a drop down list:
<style>
span[aria-owns="color_listbox"] { white-space: pre; }
#color-list .k-item { white-space: pre; }
</style>
Following a snippet
$("#color").kendoDropDownList({
dataTextField: "text",
dataValueField: "value",
dataSource: [
{ text: " [ ] Black", value: "1" },
{ text: " [ ] Orange", value: "2" },
{ text: "Grey", value: "3" }
]
});
span[aria-owns="color_listbox"] {
white-space: pre;
}
#color-list .k-item {
white-space: pre;
}
<link rel="stylesheet" href="https://kendo.cdn.telerik.com/2018.1.221/styles/kendo.bootstrap-v4.min.css" />
<script src="https://kendo.cdn.telerik.com/2018.1.221/js/jquery.min.js"></script>
<script src="https://kendo.cdn.telerik.com/2018.1.221/js/kendo.all.min.js"></script>
<input id="color" value="1" style="width: 100%;" />

2 box searchable multiselect with ajax

i am looking for a 2 box searchable multiselect along the lines of the one shown here: http://www.jqueryrain.com/?qmi2lw8H but with the left box fill-able using ajax autocomplete - i.e. you start typing 'abc' and the left box fill with everything containing 'abc' based on the jsonp results.
i have not had any luck so far using available code in the format below
<head>
<!-- BS CSS -->
<link href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" type="text/css" rel="stylesheet">
<!-- jQuery -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<!-- Multiselect/BS -->
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
<script src="http://myip/multiselect.js" language="javascript" type="text/javascript"></script>
</head>
<body>
<form method="post" name="myForm">
<div class="row">
<div class="col-xs-5">
<select name="from[]" id="search" class="form-control" size="8" multiple="multiple"></select>
</div>
<div class="col-xs-2">
<button type="button" id="search_rightAll" class="btn btn-block"><i class="glyphicon glyphicon-forward"></i></button>
<button type="button" id="search_rightSelected" class="btn btn-block"><i class="glyphicon glyphicon-chevron-right"></i></button>
<button type="button" id="search_leftSelected" class="btn btn-block"><i class="glyphicon glyphicon-chevron-left"></i></button>
<button type="button" id="search_leftAll" class="btn btn-block"><i class="glyphicon glyphicon-backward"></i></button>
</div>
<div class="col-xs-5">
<select name="to[]" id="search_to" class="form-control" size="8" multiple="multiple"></select>
</div>
</div>
<script type="text/javascript">
jQuery(document).ready(function($) {
var $select = $('#search').multiselect({
search: {
left: '<input type="text" name="q" class="form-control" placeholder="Search..." />',
right: '<input type="text" name="q" class="form-control" placeholder="Search..." />',
}
});
$select.multiselect('disable');
$.ajax({
type: "POST",
url: "../terms_by_name.php",
dataType: 'jsonp',
data: {term: request.term},
success: function OnPopulateControl(response) {
list = response.d;
if (list.length > 0) {
$select.multiselect('enable');
$("#search").empty().append('<option value="0">Please select</option>');
$.each(list, function () {
$("#search").append($("<option></option>").val(this['Value']).html(this['Text']));
});
$("#search").val(valueselected);
}
else {
$("#search").empty().append('<option selected="selected" value="0">Not available<option>');
}
$("#search").multiselect('refresh'); //refresh the select here
},
error: function () {
alert("Error");
}
});
});
</script>
</form>
the multiselect boxes display, and if i put options manually into the select that works, but the one on the left does not fill from the autocomplete.
i'm pretty new to this stuff. what am i missing?
I got this working by adding jquery ui library and using the built in autocomplete function. here's the final code:
<head>
<!-- Multiselect/BS CSS -->
<link href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" type="text/css" rel="stylesheet">
<!-- jQuery -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/jquery-ui.min.js"></script>
<!-- Multiselect/BS -->
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
<script src="http://myip/multiselect.js" language="javascript" type="text/javascript"></script>
</head>
<body>
<form method="post" name="myForm">
<div class="row">
<div class="col-xs-5">
<select name="from[]" id="search" class="form-control" size="8" multiple="multiple">
</select>
</div>
<div class="col-xs-2">
<button type="button" id="search_rightAll" class="btn btn-block"><i class="glyphicon glyphicon-forward"></i></button>
<button type="button" id="search_rightSelected" class="btn btn-block"><i class="glyphicon glyphicon-chevron-right"></i></button>
<button type="button" id="search_leftSelected" class="btn btn-block"><i class="glyphicon glyphicon-chevron-left"></i></button>
<button type="button" id="search_leftAll" class="btn btn-block"><i class="glyphicon glyphicon-backward"></i></button>
</div>
<div class="col-xs-5">
<select name="to[]" id="search_to" class="form-control" size="8" multiple="multiple"></select>
</div>
</div>
<script type="text/javascript">
jQuery(document).ready(function($) {
var $select = $('#search').multiselect({
search: {
left: '<input type="text" name="q" id="lefts" class="form-control" placeholder="Search..." />',
right: '<input type="text" name="q2" class="form-control" placeholder="Search..." />',
}
});
$select.multiselect('disable');
$( "#lefts" ).autocomplete(
{source: function (request, response) {
$.ajax({
type: "GET",
url: "http://myip/terms_by_name.php",
dataType: 'jsonp',
data: {term: request.term },
success: function OnPopulateControl(response) {
list = response;
if(list.length > 0) {
$select.multiselect('enable');
$("#search").empty().append('<option value="0">ALL</option>');
$.each(list, function () {
$("#search").append($("<option></option>").val(this['id']).html(this['value']));
});
}
else {
$("#search").empty().append('<option selected="selected" value="0">No match<option>');
}
$("#search").multiselect('refresh'); //refresh the select here
},
error: function () {
alert("Error");
}
});
},
minlength: 2
});
});
</script>
</form>
</body>

Url is getting updated but navigation is not happening on button click in angular js

I am doing POC on login application using angular js. On button click I need to navigate to another page. The code which I have written is only updating the url but the view is not getting loaded. I have used ng-view or ui- view also. And I have used $location.path. But still unable to navigate to other page
Here is my code
index.html:
<html ng-app='myApp'>
<head>
<title>Jasmine</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" />
<script src="Scripts/angular.min.js"></script>
<script src="Scripts/angular-route.min.js"></script>
<script src="routing.js" type="text/javascript"></script>
</head>
<body>
<div id='content' ng-controller='LoginController'>
<div class="container">
<form class="form-signin" role="form" name="myForm" ng-submit="login()">
<h3 class="form-signin-heading">Login Form</h3>
<span>
<b>Username :</b> <input type="text" class="form-control" ng-model="user.name" required>
</span> <br />
<br /> <span>
<b>Password :</b> <input type="password"
class="form-control" ng-model="user.password" required>
</span>
<br><br>
<button class="btn btn-lg btn-primary btn-block" type="submit" ng-disabled="myForm.$invalid">
<b>Sign in</b>
</button>
</form>
</div>
{{message}}
</div>
<div ui-view></div>
</body>
</html>
Here I have used ui-view.. when i use this, url is updating but not the view..
when i use ng-view, the script block is happening both in chrome and firefox.
routing.js:
var applog = angular.module('myApp', ['ngRoute']);
applog.controller("LoginController", function ($scope, $location, $window) {
$scope.message = "hi";
$scope.login = function () {
var username = $scope.user.name;
var password = $scope.user.password;
$location.path('/home');
};
});
applog.controller("HomeController", function ($scope, $location) {
$scope.msg = "qwerty";
});
applog.config(function ($routeProvider) {
$routeProvider
.when('/', {
templateUrl: 'index.html',
controller: 'LoginController'
}).when('/home', {
templateUrl: '/home.html',
controller: 'HomeController'
}).otherwise({
redirectTo: 'index.html'
});
});
Here I tried with hash also.. not working
Home.html:
<div ng-controller="HomeController">
Welcome....
</div>

Codeigniter - Parse error: syntax error, unexpected '-', expecting '{'

i'm new in codeigniter programming and i'm having some problems with a link to another controller.
i've got an Homepage (home.php) from wich i've to go to another page.
home.php
<?php defined('BASEPATH') OR exit('No direct script access allowed'); ?>
<!-- This is the default home page -->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Animania Manager</title>
<link rel="stylesheet" href="application/styles/foundation.css">
<link rel="stylesheet" href="application/styles/app.css">
<link rel="stylesheet" href="https://cdn.datatables.net/1.10.11/css/jquery.dataTables.min.css" />
<link rel="stylesheet" href="application/styles/reset.css"> <!-- CSS reset -->
<link rel="stylesheet" href="application/styles/style.css"> <!-- Gem style -->
<script src="application/js/modernizr.js"></script> <!-- Modernizr -->
<script src="http://code.jquery.com/jquery-1.12.0.min.js"></script>
<!--script src="http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.js"></script-->
<script src="https://cdn.datatables.net/1.10.11/js/jquery.dataTables.min.js"></script>
<script>
$(document).ready(function() {
$('#offerte').DataTable();
} );
$(document).ready(function() {
$('#curriculum').DataTable();
} );
</script>
<script>
$(document).ready(function() {
// Setup - add a text input to each footer cell
$('#offerte tfoot th').each( function () {
var title = $(this).text();
$(this).html( '<input type="text" placeholder="Cerca '+title+'" /> ');
} );
// DataTable
var table = $('#offerte').DataTable();
// Apply the search
table.columns().every( function () {
var that = this;
$( 'input', this.footer() ).on( 'keyup change', function () {
if ( that.search() !== this.value ) {
that
.search( this.value )
.draw();
}
} );
} );
} );
$(document).ready(function() {
// Setup - add a text input to each footer cell
$('#curriculum tfoot th').each( function () {
var title = $(this).text();
$(this).html( '<input type="text" placeholder="Cerca '+title+'" /> ');
} );
// DataTable
var table = $('#curriculum').DataTable();
// Apply the search
table.columns().every( function () {
var that = this;
$( 'input', this.footer() ).on( 'keyup change', function () {
if ( that.search() !== this.value ) {
that
.search( this.value )
.draw();
}
} );
} );
} );
</script>
</head>
<body>
<div class="container row">
<header class="testata" role="banner">
<nav class="menu">
<ul>
<li>Inserimento offerta</li>
<li>Inserimento CV</li>
<li></li>
</ul>
</nav>
<nav class="main-nav">
<ul>
<!-- inser more links here -->
<li><a class="cd-signin" href="#0">Login</a></li>
<li><a class="cd-signup" href="#0">Registrazione</a></li>
</ul>
</nav>
</header>
</div>
<div class="cd-user-modal"> <!-- this is the entire modal form, including the background -->
<div class="cd-user-modal-container"> <!-- this is the container wrapper -->
<ul class="cd-switcher">
<li>Login</li>
<li>Nuovo account</li>
</ul>
<div id="cd-login" action="validation.php" method=GET> <!-- log in form -->
<form class="cd-form">
<p class="fieldset">
<label class="image-replace cd-email" for="signin-email">E-mail</label>
<input class="full-width has-padding has-border" id="signin-email" type="email" placeholder="E-mail" name="email">
<span class="cd-error-message">Errore</span>
</p>
<p class="fieldset">
<label class="image-replace cd-password" for="signin-password">Password</label>
<input class="full-width has-padding has-border" id="signin-password" type="text" placeholder="Password" name="password">
Nascondi
<span class="cd-error-message">Errore!</span>
</p>
<p class="fieldset">
<input type="checkbox" id="remember-me" checked>
<label for="remember-me">Ricordami</label>
</p>
<p class="fieldset">
<input class="full-width" type="submit" value="Login">
</p>
</form>
<p class="cd-form-bottom-message">Hai dimenticato la password?</p>
<!-- Close -->
</div> <!-- cd-login -->
<div id="cd-signup"> <!-- sign up form -->
<form class="cd-form">
<p class="fieldset">
<label class="image-replace cd-username" for="signup-username">Username</label>
<input class="full-width has-padding has-border" id="signup-username" type="text" placeholder="Username">
<span class="cd-error-message">Errore!</span>
</p>
<p class="fieldset">
<label class="image-replace cd-email" for="signup-email">E-mail</label>
<input class="full-width has-padding has-border" id="signup-email" type="email" placeholder="E-mail">
<span class="cd-error-message">Errore!</span>
</p>
<p class="fieldset">
<label class="image-replace cd-password" for="signup-password">Password</label>
<input class="full-width has-padding has-border" id="signup-password" type="text" placeholder="Password">
Nascondi
<span class="cd-error-message">Errore!</span>
</p>
<p class="fieldset">
<input type="checkbox" id="accept-terms">
<label for="accept-terms">Accetto i Termini</label>
</p>
<p class="fieldset">
<input class="full-width has-padding" type="submit" value="Crea account">
</p>
</form>
<!-- Close -->
</div> <!-- cd-signup -->
<div id="cd-reset-password"> <!-- reset password form -->
<p class="cd-form-message">Hai perso la tua password? Inserisci il tuo indirizzo email. Riceverai un link per la creazione di una nuova password!</p>
<form class="cd-form">
<p class="fieldset">
<label class="image-replace cd-email" for="reset-email">E-mail</label>
<input class="full-width has-padding has-border" id="reset-email" type="email" placeholder="E-mail">
<span class="cd-error-message">Errore!</span>
</p>
<p class="fieldset">
<input class="full-width has-padding" type="submit" value="Reset password">
</p>
</form>
<p class="cd-form-bottom-message">Torna al log-in</p>
</div> <!-- cd-reset-password -->
Chiudi
</div> <!-- cd-user-modal-container -->
</div> <!-- cd-user-modal -->
<?php
if ($offers !== FALSE) {
print('<div>
<table class="display" id="offerte" cellspacing="0" width="100%">
<thead>
<tr>
<th>Titolo</th>
<th>Descrizione</th>
<th>Candidati</th>
</tr>
</thead>
<tfoot>
<tr>
<th>Titolo</th>
<th>Descrizione</th>
<th>Candidati</th>
</tr>
</tfoot><tbody>');
//for($i = 0; $i < count($offers); $i++){
foreach ($offers as $offer){
//echo base_url();
//$url=base_url('single-offerta')."?idannunci=".$offer->getId();
print("<tr>");
print("<td>".$offer->getTitolo()."</td>");
print("<td>".$offer->getDescrizione()."</td>");
//print('<td>'.$offer->getPartecipanti().'</td>');
print('<td>'.anchor('Singoff2', 'Link Text').'</td>');
print("</tr>");
}
print("</tbody></table></div>");
}
else
{
echo 'nessuna offerta';
} ?>
<!--script src="js/vendor/jquery.js"></script-->
<script src="application/js/vendor/what-input.js"></script>
<script src="application/js/vendor/foundation.js"></script>
<script src="application/js/app.js"></script>
<script src="application/js/main.js"></script> <!-- Gem jQuery -->
</div>
</body>
</html>
Singoff2.php (controller to the other page)
<?php
if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Single-offerta extends CI_Controller {
public function index()
{
$this->load->library("SingOffFactory");
//Create a data array so we can pass information to the view
$data = array(
"dettagli" => $this->singofffactory->getDettagli()
);
//Load the view and pass the data to it
$this->load->view("Singoff2", $data);
}
}
If i try my link i have the error below:
Parse error: syntax error, unexpected '-', expecting '{' in D:\inetpub\webs\animaniait\manager\application\controllers\Singoff2.php on line 4
A PHP Error was encountered
Severity: Parsing Error
Message: syntax error, unexpected '-', expecting '{'
Filename: controllers/Singoff2.php
Line Number: 4
Backtrace:
Now if i try to change the class name in my Singoff.php file i have a 404 error.
Please help me.....i'm going crazy!!
Just read the error. It is line 4 and invalid character - - hyphen. Dashes or hyphens are NOT allowed in class names.
Class name should follow file name, meaning those two need to be exact the same.
Warm advice would be to read full CI documentation. Pay attention on file naming and class and method naming. Also, it could be very helpful to read PHP OOP basics.
A valid class name starts with a letter or underscore, followed by any number of letters, numbers, or underscores. As a regular expression, it would be expressed thus: ^[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*$.
In your example file should be Single_offerta.php and line 4 should be accordingly
class Single_offerta extends CI_Controller {
If you want to access your URL with example.com/single-offerta most efficient way would be to translate uri dashes in APPPATH.'config/routes.php' file setting it to TRUE:
$route['translate_uri_dashes'] = TRUE;
rename your class name Single-offerta to something else. avoid using - in your class name

bootstrapvalidator in ajax loaded content

I will use bootstrapvalidator, as I am using bootstrap. It works fine, but I have some contents I will load via ajax. When these contents contains forms, bootstrapvalidator will not work. I create a little example to demonstrate.
It bases on the formWithoutLabels.html example of the bootstrapvalidator download.
I copy formWithoutLabels2.html to formWithoutLabels2.html and replace the content of the form with
<div id="result">
</div>
In the javascript cart I add an ajax request
$( "#result" ).load( "content.html" );
formWithoutLabels2.html:
<!DOCTYPE html>
<html>
<head>
<title>BootstrapValidator demo</title>
<link rel="stylesheet" href="../vendor/bootstrap/css/bootstrap.css"/>
<link rel="stylesheet" href="../dist/css/bootstrapValidator.css"/>
<script type="text/javascript" src="../vendor/jquery/jquery-1.10.2.min.js"></script>
<script type="text/javascript" src="../vendor/bootstrap/js/bootstrap.min.js"></script>
<script type="text/javascript" src="../dist/js/bootstrapValidator.js"></script>
</head>
<body>
<div id="result">
</div>
<script type="text/javascript">
$( "#result" ).load( "content.html" );
$(document).ready(function() {
$('#defaultForm').bootstrapValidator({
message: 'This value is not valid',
feedbackIcons: {
valid: 'glyphicon glyphicon-ok',
invalid: 'glyphicon glyphicon-remove',
validating: 'glyphicon glyphicon-refresh'
},
fields: {
username: {
message: 'The username is not valid',
validators: {
notEmpty: {
message: 'The username is required and can\'t be empty'
},
stringLength: {
min: 6,
max: 30,
message: 'The username must be more than 6 and less than 30 characters long'
},
regexp: {
regexp: /^[a-zA-Z0-9_\.]+$/,
message: 'The username can only consist of alphabetical, number, dot and underscore'
}
}
},
email: {
validators: {
notEmpty: {
message: 'The email address is required and can\'t be empty'
},
emailAddress: {
message: 'The input is not a valid email address'
}
}
},
password: {
validators: {
notEmpty: {
message: 'The password is required and can\'t be empty'
},
identical: {
field: 'confirmPassword',
message: 'The password and its confirm are not the same'
}
}
},
confirmPassword: {
validators: {
notEmpty: {
message: 'The confirm password is required and can\'t be empty'
},
identical: {
field: 'password',
message: 'The password and its confirm are not the same'
}
}
}
}
});
});
</script>
</body>
</html>
</pre>
content.html:
<div class="container" style="margin-top: 50px;">
<div class="row">
<div class="col-lg-4 col-lg-offset-4">
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">Sign up</h3>
</div>
<div class="panel-body">
<form id="defaultForm" method="post">
<div class="form-group">
<input type="text" class="form-control" name="username" placeholder="Username" />
</div>
<div class="form-group">
<input type="text" class="form-control" name="email" placeholder="Email" />
</div>
<div class="form-group">
<input type="password" class="form-control" name="password" placeholder="Password" />
</div>
<div class="form-group">
<input type="password" class="form-control" name="confirmPassword" placeholder="Retype password" />
</div>
<div class="form-group">
<button type="submit" class="btn btn-primary">Sign up</button>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
In this example bootstrapvalidator does not work. What do I need to do, that it works within the ajax request?
Any ideas?
When you load content using an AJAX query there is a window of time that you need to wait before that content appears in the DOM. You can capture the event when that content is fully loaded by assigning a callback function:
$("#result").load("content.html", function() {
// attach validation to the form here
$("#defaultForm").bootstrapValidator({
// ...
});
});
This way, the bootstrapValidator function will be assigned after the content is loaded, not before.
See the documentation for load here: http://api.jquery.com/load/

Resources