Skip to content

Instantly share code, notes, and snippets.

@KOBA789
Forked from alice1017/gist:1447401
Created December 8, 2011 16:05
Show Gist options
  • Save KOBA789/1447435 to your computer and use it in GitHub Desktop.
Save KOBA789/1447435 to your computer and use it in GitHub Desktop.
showbox.js
$(function(){
$("span#search_box").click(
function(){
if ($("span#search").css("display") == "none"){
$("span#search").slideDown("nomal");
}
else {
$("span#search").slideUp("nomal");
}
});
function smaplefunc(selector, tag_html){
selector.parent().remove();
}
$("span.input").click(function(){
var query = $("<input>").attr("type","text").attr("class","input-tag")
var s_val = $("<input>").attr("type","hidden").attr("value",$(this).parent().parent().parent().next().next().attr("status_id"));
var put = $("<input>").attr("type","submit").attr("class","add-tag").attr("value","タグを追加");
var caution = $("<span>").attr("class","caution").text("タグは半角スペースで区切ってください。大文字は小文字になります");
$(this).parent().prepend(query).append(s_val).append(put).append(caution);
$(this).remove();
$("input.add-tag").click(function(){
var that = this;
var query = $(this).prev().prev().val();
var status_id = $(this).parent().parent().parent().next().next().attr("status_id");
$.ajax({
type:"GET",
url :"/api/tag",
data:"query="+query+"&status="+status_id,
success:function(tag_html){
$(that).prev().prev().remove();
$(that).prev().remove();
$(that).next().remove();
$(that).append(tag_html);
}
});
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment