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

propagate change event. #413

Closed
3 tasks
knasser opened this issue Feb 8, 2020 · 11 comments
Closed
3 tasks

propagate change event. #413

knasser opened this issue Feb 8, 2020 · 11 comments

Comments

@knasser
Copy link
Contributor

knasser commented Feb 8, 2020

Prerequisites

  • I am running the latest version
  • I checked the documentation and found no answer
  • I checked to make sure that this issue has not already been filed

Demo Page

https://jsbin.com/degobup/edit?html,js,output

Explanation

using Tagify with Angular .. you would expect that the changes in the original input are propagated to the Angular model.
I think this is more of a general issue, I have it with angular.
the temp fix is to add line below at 1682:
this.DOM.originalInput.dispatchEvent(new Event('change'));

Perhaps you want to validate and see if the change goes with your design or there is a better fix.

  • What is the expected behavior?
    using Tagify with Angular .. you would expect that the changes in the original input are propagated to the Angular model.

  • What is happening instead?
    Angular model is not updated with the changes

  • What error message are you getting?

@yairEO
Copy link
Owner

yairEO commented Feb 9, 2020

A friend helped me with the Angular port, she did it all as I have zero knowledge or interest in Angular.. To make any fixes I would require a reliable PR :)

@yairEO yairEO assigned yairEO and unassigned yairEO Feb 9, 2020
@knasser
Copy link
Contributor Author

knasser commented Feb 10, 2020

see this one:
https://jsbin.com/jenizorilu/edit?html,js,output

if you disable tagify .. the change event is fired from the textarea once you change it..
after enabling tagify the change event is blocked..

will create the PR.. though not sure this is the best solution you would use.

@yairEO
Copy link
Owner

yairEO commented Feb 10, 2020

Your demo page has no Angular.
What do you mean "if you disable tagify". How did you disable it? in what manner do you consider it disabled?

and how do you "enable" it back? what is happening in between?

@knasser
Copy link
Contributor Author

knasser commented Feb 10, 2020

yes.. no angular .. tried simplest config to demonstrate it is a general consideration.
disable == comment out the call to tagify :) ==> you get the change event (i.e. the alert popsup)
enable == uncomment.. ==> with tagify the alert doesnt appear..

@yairEO
Copy link
Owner

yairEO commented Feb 10, 2020

But why do you need a change event on an textarea?
What is the logic here, the flow?

@knasser
Copy link
Contributor Author

knasser commented Feb 10, 2020

the onchange is used to bind the "original" input to the model (plain object)
once changed the model is serialised to json and saved to the database.

@yairEO
Copy link
Owner

yairEO commented Feb 10, 2020

Why do you need to bind the "original" input? you only need to populate it with data, but not the other way around, which is to use an "onChange" event listener for it, and work directly with Tagify's events. This sounds similar to this issue:

#364

@knasser
Copy link
Contributor Author

knasser commented Feb 10, 2020

Tagify events could work but I think it is a bit more invasive..
In general, when you have already an application developed and you want to add tagify features.. if tagify fires the update event on the original input, you dont need to change anything with your original application other than tagifying the inputs.... this is the approach used by other decorators like tagify.. e.g. Select2

In my case, it is quite destructive to do it via Tagify .. The application depends on Angular and schema form (http://schemaform.io/) to bind the form inputs to the model objects automatically upon any changes to the complete form .. if the events are not propagating we will have to rewrite the binding between tagify and the all the forms again..

for us that line in the PR is doing the trick and tagify is working like a charm with angular and schemaform .. :) thought about sharing

@yairEO
Copy link
Owner

yairEO commented Feb 11, 2020

ok sounds good to me, I will look into this

@yairEO
Copy link
Owner

yairEO commented Feb 23, 2020

fixed

@yairEO yairEO closed this as completed Feb 23, 2020
@knasser
Copy link
Contributor Author

knasser commented Feb 25, 2020

yep.. got the latest version.. works nicely. 👍

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

No branches or pull requests

2 participants