How to call Save First window on unlocking?

Hi there, I have a form with multiple properties. I'm editing these properties from a javascript attached to an html page.However, when  I change the value of a form field and unlock the item it doesn't ask me if I want to save first. Do you, guys, know how can I get this window to show on item unlock event after a field value is changed?   Thanks. p.s. I'm setting the value by using:
item.setProperty(id,value); var p = item.apply();