I am facing a little issue in my jQuery script.
So, I have a function set_fav_item to set my item after editing it. After that is done, I want to execute another function. I don't understand why it is not working, since I do it well elsewhere in my script...
My function set_fav_item() :
function set_fav_item(){
var postid = $("#window-edit input#postid").val();
var icon = $("#window-edit span.selected-icon > i").clone();
var color = $("#window-edit button.jscolor").css("background-color");
var edited_item = $("#fav-items #"+postid+"");
edited_item.css("background-color",color);
icon.appendTo($("#fav-items #"+postid+" a"));
$("#window-edit , .overlay").hide(400);
}
My try :
$("#window-edit #send").on("click",function(){
// item with id #242 is an example
$.when(set_fav_item()).then(console.log($("#242").css('background-color')));
});
When I edit the color of my item in my edit box and click on save button (id = #send), then the console.log gives me back the old color not the new one.
If I use my browser console to check the $('#242') background color, i got the new one as expected.
Many thanks for your help.
Sommy
set_fav_itemis not returning a promisethen