Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added new property form.isDataChanged #4

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

rizsc
Copy link
Contributor

@rizsc rizsc commented Jun 14, 2013

Added new property in form object, its useful to updating records if data has changed.

form.isDataChanged = true/false;

also fixed code if (defaultProperties.bindAll === true) {...
maybe it was wrong, it wasn't binding all elements. so I changed it to true ;)

Thanks!
Riz

Added new property in form object, its useful to updating records if data has changed.

form.isDataChanged = true/false;

also fixed code if (defaultProperties.bindAll === true) {...
maybe it was wrong, it wasn't binding all elements. so I changed it to true ;)

Thanks!
Riz
@jdavidw13
Copy link
Owner

What, exactly, is the purpose of isDataChanged? Changing form fields will update the model you initially bound with. For example:

<form>
   <input type="text" name="field" />
</form>
var bean = {field: 'bob'};
$('form').binddata(bean);
// field will be set to bob, and if you change bob to something else
// bean.field will equal what you entered

The bindAll option is used when you don't want certain changes in the form to be reflected in the model that was passed to binddata(). Specifically, only properties that exist in the model when binddata is called will be updated.

<form>
   <input type="text" name="prop1" />
   <input type="text" name="prop2" />
</form>
var bean = {prop1:'prop1'};
$('form').binddata(bean, {bindAll: false});
bean.prop2 = "I don't want this changed";
// if the user changes the prop2 field, it won't be reflected in bean.prop2, because bindAll was false
// or...
var bean = {prop1:'prop1'};
$('form').binddata(bean);
bean.prop2 = 'prop2';
// now when the user changes the prop2 field, bean.prop2 will get those changes.

If not all properties of the model were being bound, it must be a bug. Can you create a test to demonstrate the bug, and we can troubleshoot from there? I will want to merge the textarea change though :)

@rizsc
Copy link
Contributor Author

rizsc commented Jun 18, 2013

isDataChanged is for to check records is changed or not before sending request to server, so I added to the on element change event to the main selected form as form object property, so whenever form is updated then that property will be true, this will help to prevent posting same records to the server.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants