eldarion / eldarion-ajax

a library for adding declarative ajax functionality to your website
BSD 3-Clause "New" or "Revised" License
758 stars 153 forks source link

some design questions #74

Closed cemo closed 10 years ago

cemo commented 10 years ago

Hi @paltman,

I have some issues regarding your implementation and could not find a better place to ask them.

  1. _ajax function triggers a complete event over document object instead of $el object at here. What is the reason about this?
  2. _ajax function is using triggerHandler instead of trigger for modify-data. Why?
  3. There are some cases I need to reach submitted data in handling functions. What do you suggest? Should I send a PR for this?

I am sure you have pretty good reasons for them and I would be glad if you enlighten me.

paltman commented 10 years ago

@cemo thank you for your comments and questions.

  1. I was using document instead of $el because in there are cases where certain handlers will replace or remove the node represented by $el and then you lose the handle for that event to be caught. By passing it as an argument you can still get out what it used to be and filter things in your eldarion-ajax:complete handler by inspecting properties of the $el argument using things like hasClass. I welcome a better implementation but this what I was able to come up with and it works so I stopped working on it. :)
  2. No reasons. Based on my understanding, either of these two will work the same for the purposes I am using it for here. The biggest difference is trigger will bubble up the event while triggerHandler does not. Do you need the event to bubble?
  3. I, too, have hit this case several times, but have always worked around it. Would love to see a PR with your ideas.

Thanks, Patrick