You don't need to make a new jQuery object to do that.
Fixed typo in the click param Cache the .edit_photo jQuery object
This commit is contained in:
parent
fb13ff2212
commit
c8e8ef06e7
1 changed files with 10 additions and 8 deletions
|
|
@ -8,18 +8,20 @@ $(document).keydown(function(e){
|
|||
switch(e.keyCode) {
|
||||
case 37:
|
||||
if(!$("textarea").hasClass("hasfocus")){//prevent redirect if textarea has focus
|
||||
window.location = $("#prev_photo").attr('href');
|
||||
window.location = document.getElementById("prev_photo").href;
|
||||
}
|
||||
break;
|
||||
case 39:
|
||||
if(!$("textarea").hasClass("hasfocus")){
|
||||
window.location = $("#next_photo").attr('href');
|
||||
window.location = document.getElementById("next_photo").href;
|
||||
}
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
$(document).ready(function(){
|
||||
var $edit_photo = $(".edit_photo");
|
||||
|
||||
//add a clas to verify if a textarea has focus
|
||||
$("textarea").live('focus',function(){
|
||||
$(this).addClass("hasfocus");
|
||||
|
|
@ -34,13 +36,13 @@ $(document).ready(function(){
|
|||
});
|
||||
|
||||
//Add a description with ajax request
|
||||
$("#photo_submit").click(function(evenet){
|
||||
$("#photo_submit").click(function(event){
|
||||
event.preventDefault();
|
||||
var method = $(".edit_photo").attr("method");
|
||||
var url = $(".edit_photo").attr("action");
|
||||
var data = $(".edit_photo").serialize();
|
||||
$(".description").text($("#photo_caption").val());
|
||||
$(".edit_photo").toggle();
|
||||
var method = $edit_photo.attr("method");
|
||||
var url = $edit_photo.attr("action");
|
||||
var data = $edit_photo.serialize();
|
||||
$(".description").text(document.getElementById("photo_caption").value);
|
||||
$edit_photo.toggle();
|
||||
|
||||
$.ajax({
|
||||
type: method,
|
||||
|
|
|
|||
Loading…
Reference in a new issue