I am trying to fill my notification popover with AJAX. I have two popovers on the same page. The other popover's content is filled by PHP. The AJAX works fine.
The problem is that the notification popover is being displayed where the other popover is and not below where I am clicking. This problem only occurs when the data content is taken from AJAX. Content produced from PHP or some string works as expected.
Below is the code for the AJAX popover:
$(document).ready(function() {
$('#npop').popover({
template: '<div class="popover"><div class="arrow"></div><div class="popover-inner"><h3 class="popover-title"></h3><div class="popover-content" style="padding:0px;overflow-y:auto;max-height:450px;"><p></p></div></div></div>',
html: true,
placement: 'bottom',
title: 'Notifications',
content: function(){
var div_id = "tmp-id-" + $.now();
return details_in_popup(div_id);
}
});
});
function details_in_popup(div_id){
$.ajax({
url: "<?php echo base_url('pull_notify'); ?>",
success: function(response){
$('#'+div_id).html(response);
}
});
return '<div id="'+ div_id +'">Loading...</div>';
}
And this is my HTML element:
<div class="notification-icon navbar-brand">
<span>
<a style="color: #008ae6;font-size:25px;" id="npop" class="glyphicon glyphicon-bell" role="button" data-toggle="popover" ></a></span>
<span id="bad" class="badge badge-notify"></span>
</div>
Ok Solved the issue.
Changed the return div with
return '<div id="'+ div_id +'" style="width: 400px; padding-right: 10px">Loading...</div>';
Apparently the fix was adding a style to the div with a specified width and some css changes in template.
Below is the code
$('#npop').popover({
template: '<div class="popover"><div class="arrow"></div><div class="popover-inner"><h3 class="popover-title"></h3><div class="popover-content" style="padding:0px;overflow-y:auto;max-height:450px; width: 400px"><p></p></div></div></div>',
html: true,
placement: 'bottom',
title: 'Notifications',
content: function(){
var div_id = "tmp-id-" + $.now();
return details_in_popup(div_id);
}
});
});
function details_in_popup(div_id){
$.ajax({
url: "<?php echo base_url('pull_notify'); ?>",
success: function(response){
$('#'+div_id).html(response);
}
});
return '<div id="'+ div_id +'" style="width: 400px; padding-right: 10px">Loading...</div>';
}
PS: I am also using the below css,
.popover{
max-width: 600px !important;
max-height: 500px !important;
}
.popover div{
overflow-x: hidden !important;
}
Related
I have a live search functionality which returns a complete li element and append it to some container afterwards. But the tooltip is not working. Here is my code:
$(".hb_search_text_job").on('keyup', function() {
var search_val = $('.hb_search_text_job').val();
var current_user_id = $('.hb_footer_user_id').val();
if(search_val.length > 2){
$.ajax({
type: "POST",
url: "<?php echo admin_url('admin-ajax.php'); ?>",
data: { action: 'search_jobs_list',
current_user_id: current_user_id,
search_val: search_val
},
success: function(data) {
$('#hb_sidebarmenu li .submenu li .submenu li').remove();
$.each(JSON.parse(data), function(key,val) {
$('#hb_sidebarmenu li .submenu li .submenu .hb_job_listing').append(val);
},
error: function() {
console.log('ERROR');
}
});
}
});
And here is the sample of the return code:
<li data-rel='tooltip' rel='tooltip' title='A tooltip yay!'>";
<a href='#' class='hb_job_id_link'>";
<div class='hb_menu_name'>My li name</div>";
</a></li>";
Any possible idea or solution?
You will need to reinitialize the tooltio after adding the content.
success: function(data) {
$('#hb_sidebarmenu li .submenu li .submenu li').remove();
$.each(JSON.parse(data), function(key,val) {
$('#hb_sidebarmenu li .submenu li .submenu .hb_job_listing').append(val);
}
$("[data-rel='tooltip']").tooltip(); // Re-init tooltip
},
I'm trying to implement a commenting box with AJAX and PHP (CodeIgniter framework). Here is the code.
The view (HTML code):
<form id="form" method="post">
<div class="input-group" id="input-group"><!-- input group starts-->
<textarea class="form-control" id="Comment" name="Comment" placeholder="Comment on Scenery..." maxlength="300" cols="70" rows="3" required></textarea>
<input type="hidden" id="uploader_id" value="<?php echo $uploader_id ?>"/>
<input type="hidden" id ="scenery_id" value="<?php echo $scenery_id ?>"/>
<button type="submit" id="submit"class="btn btn-info regibutton" >Post</button>
</div>
</form>
<hr/>
<div class="comment-block">
<?php
if ($comment==NULL){
//if no scenery comment echo disclaimer
echo " <ul style = ' margin-left: 0px;padding-left: 0px;'> <li style = 'list-style: none; background-color: #fff; padding : 5px 5px 5px 10px; margin: 5px 5px 5px 5px'>";
echo " No scenery Comments";
echo "</li>
</ul>";
} else {
foreach ($comment as $row){
// if the comments are availabe echo them
echo " <ul style = ' margin-left: 0px;padding-left: 0px;'> <li style = 'list-style: none; background-color: #fff; padding : 10px 5px 5px 10px; margin: 5px 5px 5px 5px'>";
echo $row->Comment;
echo "<br/>";
echo "<p style='font-size: 11px; color:#333; padding-top: 5px;'>".date(" D d M Y - H:i:s ",strtotime($row->Date_posted))."By - ". $row->Username. " </p>";
echo $row->Date_added;
echo "</li>
</ul>";
}
}
?>
</div>
The AJAX code:
<script>
$(document).ready(function(){
$('#submit').click(function(e){
// remove the error class
$('.input-group').removeClass('has-error');
//remove the previous
$('.help-block').remove();
var Comment = $('#Comment').val();
var scenery_id = $('#scenery_id').val();
var uploader_id = $('#uploader_id').val();
var datastring = 'Comment'+Comment+'&scenery_id'+scenery_id+'&uploader_id'+uploader_id;
$.ajax({
type:'POST',
url: "<?php echo base_url('display_scenery/add_comment')?>",
data: datastring,
datatype: 'json',
cache: 'false',
encode: true
});
.done(function(data) {
// log data to the console so we can see
console.log(data);
// here we will handle errors and validation messages
if(!data.success){
$('#data.errors.input-group'){
$('#iput-group').addClass('has-error');
$('#iput-group').append('<div class= "help">' + data.errors.Comment+'</div>');
} else {
$('#form').append('<div class="alert">'+ data.message+'</div>');
}
)};
.fail(function(data) {
// show any errors
// best to remove for production
console.log(data);
});
}*/
// prevent default action
e.preventDefault();
});
});
</script>
The back end code in CodeIgniter:
public function add_comment(){
if(!$this->session->userdata('logged_in')) {
$data['error'] = 'Signup needed to comment on a scenery';
} else {
$this->load->library('form_validation');
$session_data = $this->session->userdata('logged_in');
$User_id= $session_data['User_id'];
$scenery_id = $_POST['Scenery_id'];
$Comment=$_POST['Comment'];
$this->form_validation->set_rules('Comment', 'Comment', 'trim|required');
if($this->form_validation->run() == FALSE) {
$data['error'] = validation_errors();
} else {
//loads the model image_display then redirects to scenery page
$this-> image_display->add_comment( $scenery_id,$User, $Comment);
$data['Comment']=$this-> image_display->get_comments($scenery_id);
$data['success'] = TRUE;
}
}
echo json_encode($data);
}
I want a system where the user can comment and the comments can be displayed. I'm trying to locate why the code is not working,kindly assist, I'm relatively new to AJAX.
try this :
<script>
$(document).ready(function(){
$('#submit').click(function(e){
// remove the error class
$('.input-group').removeClass('has-error');
//remove the previous
$('.help-block').remove();
var datastring = $("#form").serialize();
$.ajax({
type:'POST',
url: "<?php echo base_url('display_scenery/add_comment')?>",
data: datastring,
datatype: 'json',
cache: 'false',
encode: true
});
.done(function(data)
{
// log data to the console so we can see
console.log(data);
// here we will handle errors and validation messages
if(!data.success){
$('#data.errors.input-group'){
$('#iput-group').addClass('has-error');
$('#iput-group').append('<div class= "help">' + data.errors.Comment+'</div>');
}
else
{
$('#form').append('<div class="alert">'+ data.message+'</div>');
}
)};
.fail(function(data) {
// show any errors
// best to remove for production
console.log(data);
});
}*/
// prevent default action
e.preventDefault();
});
});
</script>
There is a list of checkboxes. User clicks on image of a "unchecked checkbox". Ajax sends request to php script which updates database and echo's new image source of a "checked checkbox". This works fine, and is below:
HTML:
<img src="<?php echo ( $box->complete == 1 ) ? "/images/checkbox-filled.png" : "/images/checkbox-empty.png" ?>" id="checkbox-<?php echo $box->id ?>" />
markBox.js:
$.ajax( {
type: "POST",
url: "/scripts/markBox.php",
data: data,
cache: false,
success: function( imageSource ) {
image.attr( 'src', imageSource );
}
} );
markBox.php:
//Return result
if ( $box->complete == 1 )
echo "/images/checkbox-filled.png";
else
echo "/images/checkbox-empty.png";
exit;
The challenge is that I have php function that is called earlier, above the list of checkboxes, to display to user how boxes are checked and how many are not. I want this box to be called and refresh as the image does. How do I rerun the php function to run again once the ajax comes back?
HTML:
<div class="markBox"><?php echo $results->getCountComplete() ?> Complete</div>
<div class="markBox"><?php echo $results->getCountNotComplete() ?> Incomplete</div>
you don't need ajax at all: (unless you don't want to store your data to a database or a file): I hope this helps:
http://jsfiddle.net/teeEx/
HTML:
<span class="checked"> </span>
<span class="unchecked"> </span>
<span class="unchecked"> </span>
<div id="result"></div>
CSS:
a{
text-decoration: none;
}
span{
display: block;
width: 30px;
height: 30px;
margin: 20px;
}
span.checked{
background: green;
}
span.unchecked{
background: black;
}
JS:
$('a').click(function(){
var a_obj = $(this);
var obj = a_obj.children('span');
if( obj.is('.checked')){
obj.removeClass('checked').addClass('unchecked');
} else {
obj.removeClass('unchecked').addClass('checked');
}
var all = a_obj.parent();
var countChecked = all.find('span.checked').length;
var countunChecked = all.find('span.unchecked').length;
$('#result').html('checked '+countChecked+'; unckecked: '+countunChecked);
});
I'm trying to make a progress bar which works with $.ajax(jquery) and php for a file uploader but I dont know how to assemble it. I know there is a progress bar working with jQuery UI; how ever, it just change while receiving a value. And that's the point. How can I get a dinamic value for the byte uploded?
By the way, this is my code:
fx_file.js
/*This function gets Data from the form and send it to server*/
function fiEnviarDatos2(){
$("form#data").click(function(){
/*Some DOM'S animations*/
});
$("form#data").submit(function(){
var formData = new FormData($(this)[0]);
$.ajax({
url: "PHP/Core/Archivos/upload.php",
type: 'POST',
data: formData,
async: false,
success: function (data) {
/*After actions**/
},
progress:function(data){
alert(data);
},
cache: false,
contentType: false,
processData: false
});
return false;
});`
upload.php
<?php include ("Class_upload.php");
/*Variables*/
$i=0;
$archivos=0;
/*Contains numbers of file sent*/
$archivos=((count($_FILES,1)-6)/5);
/*Contains the user's session name*/
session_start();
$sUsuario=$_SESSION['usuario'];
/*Use the information of each file to create a new class Upload*/
for($i=0;$i<$archivos;$i++){
/*FileSize*/
$tamaArchivo = $_FILES['formUploader']['size'][$i];
/*Filename*/
$nombArchivo = strtolower($_FILES['formUploader']['name'][$i]);
/*Filetemp*/
$tmpArchivo = $_FILES['formUploader']['tmp_name'][$i];
/*It creates class Upload*/
$archivo_subir=new Upload($nombArchivo,$tamaArchivo,$tmpArchivo,$sUsuario);
/*It validates each file and returns a status*/
$estatus=$archivo_subir->enviarData();
/*Returns if file's been uploaded or not*/
$resultFile=$archivo_subir->resultFile($estatus);
echo "<br>";
if($estatus>0){
echo "<div class='resultDeny'>".$resultFile."</div>";
}else{
if($resultFile=="ServerError"){
echo "<div class='resultServer'>".$resultFile."</div>";
}else{
echo "<div class='resultSuccess'>".$resultFile."</div>";
}
}
}
I hope I can found some help from you, guys. I know you all are expert. I'm new working with jquery and php; however , i've seen "their power together" and i want to learn more about them.
Thanks for all.
PDT: Sorry for my english, it's not my mother language. JQ &PHP will be.
Check this page out:
http://www.johnboy.com/php-upload-progress-bar/
http://www.johnboy.com/php-upload-progress-bar/upload_frame.phps
basically
function(data) //return information back from jQuery's get request
{
$('#progress_container').fadeIn(100); //fade in progress bar
$('#progress_bar').width(data +"%"); //set width of progress bar based on the $status value (set at the top of this page)
$('#progress_completed').html(parseInt(data) +"%"); //display the % completed within the progress bar
}
)},500);
after investigating almost all day , I achieved what I wanted.
I found this plugin called JQUERY Form Plugin.
[http://malsup.com/jquery/form/][1]
Maybe some of you have used it. It has almost all the necessary options to built a progressbar and to introduce code before and after submitting the form.
So, check it out. Maybe someone finds it useful
Btw , this is how my code looks like now
accountUser.html
<html>
//...
...//
<style>
form { display: block; margin: 20px auto; background: #eee; border-radius: 10px; padding: 15px }
.progress { position:relative; width:400px; border: 1px solid #ddd; padding: 1px; border-radius: 3px; margin-top:-200px }
.bar { background-image:url(Imagenes/index/pbar-ani.gif); width:0%; height:20px; border- radius: 3px; }
.percent { position:absolute; display:inline-block; top:3px; left:48%; }
</style>
<script language="javascript" src="Scripts/jquery_min_1.8.js"></script>
<script language="javascript" src="Scripts/fx_file.js"></script>
<script language="javascript" src="Scripts/jquery.form.js"></script>
//...
..//
<form action="#" method="post" enctype="multipart/form-data" id="formu">
<input name="formUploader[]" type="file" multiple id="archivo"/>
<input class="button" type="submit" alt="Upload" value="Subir" id="btn_cargar"/>
</form>
<div class="progress">
<div class="bar"></div >
<div class="percent">0%</div >
</div>
//...
..//
</html>
fx_file.js
$(document).ready(function() {
// prepare Options Object
var bar = $('.bar');
var percent = $('.percent');
var status = $('#status');
var options = {
url: "upload.php",
type: 'POST',
uploadProgress: function(event, position, total, percentComplete) {
var percentVal = percentComplete + '%';
$(bar).animate({width:percentVal});
percent.html(percentVal);
},
success: function(data){
//After actions
}
};
// bind 'formu' and provide a simple callback function
$('#formu').ajaxForm(options);
});
upload.php
<?php include ("Class_upload.php");
/*Variables*/
$i=0;
$archivos=0;
/*Contains numbers of file sent*/
$archivos=((count($_FILES,1)-6)/5);
/*Contains the user's session name*/
session_start();
$sUsuario=$_SESSION['usuario'];
/*Use the information of each file to create a new class Upload*/
for($i=0;$i<$archivos;$i++){
/*FileSize*/
$tamaArchivo = $_FILES['formUploader']['size'][$i];
/*Filename*/
$nombArchivo = strtolower($_FILES['formUploader']['name'][$i]);
/*Filetemp*/
$tmpArchivo = $_FILES['formUploader']['tmp_name'][$i];
/*It creates class Upload*/
$archivo_subir=new Upload($nombArchivo,$tamaArchivo,$tmpArchivo,$sUsuario);
/*It validates each file and returns a status*/
$estatus=$archivo_subir->enviarData();
/*Returns if file's been uploaded or not*/
$resultFile=$archivo_subir->resultFile($estatus);
echo "<br>";
if($estatus>0){
echo "<div class='resultDeny'>".$resultFile."</div>";
}else{
if($resultFile=="ServerError"){
echo "<div class='resultServer'>".$resultFile."</div>";
}else{
echo "<div class='resultSuccess'>".$resultFile."</div>";
}
}
}//End For
<?php>
I did some googling and figured I'm probably experiencing so called "event bubbling" that I've never heard of but are not surprised by it's existance. I want it to fire only once and I'm wondering how to fix this.
Basically, I have this small code snippet:
$('.bggallery_images').click(function () {
alert('test');
});
This is supposed to fire once from a php snippet that basically adds an image of each image from a specific folder. It then outputs an echo string where each image has the class of "bggallery_images".
PHP snippet looks like this:
<?php
$dirname = "img";
$images = scandir($dirname);
$ignore = Array(".", "..");
foreach($images as $file)
{
if(!in_array($file, $ignore))
{
echo "<img class=\"bggallery_images\" src=\"$dirname/$file\" />";
};
}
?>
This all generates the html markup that looks like this for each image:
<img src="img/WhitePattern6.gif" class="bggallery_images">
What is happening here?
Here's the rendered output from FireBug:
<div id="gallery_lightbox" style="height: 215px; z-index: 4; display: block;">
<div id="close"></div>
<h2><cufon class="cufon cufon-canvas" alt="Velg " style="width: 39px; height: 20px;"><canvas width="49" height="23" style="width: 49px; height: 23px; top: -4px; left: 0px;"></canvas><cufontext>Velg </cufontext></cufon><cufon class="cufon cufon-canvas" alt="bakgrunnsbilde" style="width: 123px; height: 20px;"><canvas width="129" height="23" style="width: 129px; height: 23px; top: -4px; left: 0px;"></canvas><cufontext>bakgrunnsbilde</cufontext></cufon></h2>
<div class="bggallery_images">testererererer</div>
<img src="img/Bakgrunner/4462-v4.jpg" class="bggallery_images"><img src="img/Bakgrunner/5922.gif" class="bggallery_images"><img src="img/Bakgrunner/BluePattern.gif" class="bggallery_images"><img src="img/Bakgrunner/Brown1.gif" class="bggallery_images"><img src="img/Bakgrunner/Brown2Pattern.jpg" class="bggallery_images"><img src="img/Bakgrunner/BrownPattern.jpg" class="bggallery_images"><img src="img/Bakgrunner/Brownn.gif" class="bggallery_images"><img src="img/Bakgrunner/GrayPattern.gif" class="bggallery_images"><img src="img/Bakgrunner/GreenPattern3.gif" class="bggallery_images"><img src="img/Bakgrunner/OrangePattern.gif" class="bggallery_images"><img src="img/Bakgrunner/PurplePattern.gif" class="bggallery_images"><img src="img/Bakgrunner/PurplePattern2.gif" class="bggallery_images"><img src="img/Bakgrunner/RedPattern3.gif" class="bggallery_images"><img src="img/Bakgrunner/RedPattern4.gif" class="bggallery_images"><img src="img/Bakgrunner/RedPattern5.gif" class="bggallery_images"><img src="img/Bakgrunner/Tiled_Wallpaper__Green_Texture_by_knitetgantt.png" class="bggallery_images"><img src="img/Bakgrunner/WhitePattern4.gif" class="bggallery_images"><img src="img/Bakgrunner/WhitePattern5.gif" class="bggallery_images"><img src="img/Bakgrunner/WhitePattern6.gif" class="bggallery_images"><img src="img/Bakgrunner/WhitePattern7.gif" class="bggallery_images"><img src="img/Bakgrunner/WhitePurple.jpg" class="bggallery_images"><img src="img/Bakgrunner/YellowPattern.gif" class="bggallery_images"><img src="img/Bakgrunner/vintage-wallpaper.jpg" class="bggallery_images">
</div>
Edit: Here's the js.js file basically. I didn't include the kwicks slidemenu script though.
/* ********************************************** */
/* DOCUMENT READY */
/* ********************************************** */
$(document).ready(function () {
bg_gallery();
});
/* ********************************************** */
/* Background gallery changer */
/* ********************************************** */
function bg_gallery() {
// Sett nytt bakgrunnsbilde i CSSen
var originalBG = $('#wrapper').css('background-image');
$('.bggallery_images').click(function () {
var newBG = "url('" + $(this).attr('src');
var fullpath = $(this).attr('src');
var filename = fullpath.replace('img/Bakgrunner/', '');
$('#wrapper').css('background-image', newBG);
alert('test');
// Lagre til SQL
/*alert('Test');
$.ajax({
url: 'save_to_db.php', // The url to your function to handle saving to the db
data: filename,
dataType:'Text',
type: 'POST', // Could also use GET if you prefer
success: function(data) {
// Just for testing purposes.
//alert('Background changed to: ' + data);
}
});*/
});
// Få frem galleriet
$('.bggallery_current_image').click(function () {
$('html, body').animate({scrollTop:0}, 'slow');
$('#gallery_lightbox').css('height','215px'); // Sett høyde på lightbox-dings
$('#gallery_lightbox').css('z-index','4'); // Sørg for at boksen er i øverste lag
$('body').append('<div id="bggallery_overlay"></div>');
$('#bggallery_overlay').css('height', $(document).height ());
$('#bggallery_overlay').css('width', $(document).width ());
$('#bggallery_overlay').fadeIn('fast',function(){$('#gallery_lightbox').fadeIn('slow');});
});
$('#close').click(function () {
$('#bggallery_overlay').fadeOut('fast',function(){$("#bggallery_overlay").remove();}); //callback, vent
$('#gallery_lightbox').fadeOut('slow');
});
};
/* ********************************************** */
/* Content loader (swoosh ut-swosh inn) */
/* ********************************************** */
/* Load kun fra dynload-klasser, må wrappe en div f. eks rundt slike a href linker */
$('.dynload').die('click').live('click', function () {
$('#ajaxloader').fadeIn('fast');
$('#ajaxloaderfridge').fadeIn('fast');
var href = this.href + ' #content';
var height_initially = $('#container').height();
$('#content').slideUp('fast', function () {
$('#content').fadeOut('fast');
var height_current = $('#container').height();
$(this).load(href, '', function (data) {
createSlidemenus();
bg_gallery();
$('#ajaxloader').fadeOut('fast');
$('#ajaxloaderfridge').fadeOut('fast');
$("#content").animate({
height: 'show',
opacity: 'show'
}, 'normal');
$('#content').show('fast');
Cufon.replace('h1, h2, h3, h4, .menuwrapper', {
fontFamily: 'advent'
});
});
});
return false;
});
$(createSlidemenus);
function createSlidemenus() {
$('#kontrollpanel .slidepanels').kwicks({
min: 42,
spacing: 3,
isVertical: true,
sticky: true,
event: 'click'
});
}
Check out the following link to clarify event bubbling: http://www.quirksmode.org/js/events_order.html
You can prevent bubbling by just returning "false" from the event handler:
$('.bggallery_images').click(function () {
alert('test');
return false;
});
Edit: This code works without producing two alerts so it must be something external to this.
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/DTD/strict.dtd">
<html>
<head>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script>
</head>
<body>
<div id="gallery_lightbox" style="height: 215px; z-index: 4; display: block;">
<div id="close"></div>
<h2>
<cufon class="cufon cufon-canvas" alt="Velg " style="width: 39px; height: 20px;">
<canvas width="49" height="23" style="width: 49px; height: 23px; top: -4px; left: 0px;"></canvas>
<cufontext>Velg</cufontext>
</cufon>
<cufon class="cufon cufon-canvas" alt="bakgrunnsbilde" style="width: 123px; height: 20px;">
<canvas width="129" height="23" style="width: 129px; height: 23px; top: -4px; left: 0px;"></canvas>
<cufontext>bakgrunnsbilde</cufontext>
</cufon>
</h2>
<div class="bggallery_images">testererererer</div>
<img src="http://google.com/images/srpr/nav_logo13.png" class="bggallery_images"/>
<img src="http://google.com/images/srpr/nav_logo13.png" class="bggallery_images"/>
</div>
<script type="text/javascript">
$('.bggallery_images').click(function () {
alert('test');
});
</script>
</body>
</html>
I've created a test page from the html and js instruction you posted and can't reproduce your error- the alert only fires once. I'm using this for a jquery reference:
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.js"></script>
and this at the end to start things up
<script>
$('.bggallery_images').click(function() {
alert('test');
});
</script>
you're doing something you're not telling us about or firebug is lying to you. it's possible the html that firebug is showing you (as it's interpreted) is different than the physical source of the page. can you post a complete example of your output which demonstrates the problem?
You might want to have a look at the jquery .bind() method.
The following is taken from the jquery docs page
Example: Cancel a default action and prevent it from bubbling up by returning false:
$("form").bind("submit", function() { return false; })
Example: Stop an event from bubbling without preventing the default action by
using the .stopPropagation() method.
$("form").bind("submit", function(event) {
event.stopPropagation();
});