Это часть функции:
var editid;
$("div.editable").click(function(e) {
if ($currentInput == null)
return;
var css = GetCssProperties();
$(this).css(css);
editid = $(this).attr("id");
$currentInput = null;
$("label").html("");
});
Я думаю, что проблема здесь.Если потребуется, я опубликую все это.
По сути, при первом сохранении var editid это неопределенное значение.
Переменная отправляется на страницу PHP, и я заставил ее повторить результат обратно на страницу.
В обязательном порядке, при первом сохранении значения при нажатии "undefined "и каждый раз, когда он хранит соответствующее значение.
Вот и все:
<script>
$(document).ready(function(){
var $currentInput = null;
$("#border_button, #background_color_button, #opacity_button").click(function() {
if ($currentInput == null) {
$currentInput = $(this).prev();
$("label").html($currentInput.attr("id"));
}
});
var editid;
$("div.editable").click(function(e) {
if ($currentInput == null)
return;
var css = GetCssProperties();
$(this).css(css);
editid = $(this).attr("id");
$currentInput = null;
$("label").html("");
});
function GetCssProperties() {
if ($currentInput == null) return null;
var value = $currentInput.val();
if ($currentInput.attr("id") == "background-color") {
ajaxStyle(value, 1, editid)
return {
"background-color": value
}
}
if ($currentInput.attr("id") == "border-radius") {
ajaxStyle(value, 2, editid)
return {
"border-radius": value
}
}
if ($currentInput.attr("id") == "opacity") {
ajaxStyle(value, 3, editid)
return {
"opacity": value
}
}
}
});