vojtech-dobes / nette.ajax.js

Flexible AJAX for Nette Framework. Supports snippets, redirects etc.
https://componette.org/vojtech-dobes/nette.ajax.js/
MIT License
149 stars 85 forks source link

Ajax behavior incompatible with .prop() behavior (as well as absolute urls) #70

Open Majkl578 opened 11 years ago

Majkl578 commented 11 years ago

Hi, I've just spent about an hour debugging why my ajax link doesn't work. I had an anchor:

<a href="#">Foo</a>

And I was dynamically changing its href after click on another element. I was using .prop() to change anchor's href. After changing it to .attr(), ajax started working. Really a WTF. My question is: Is it a bug or a hidden feature with no warning?

vojtech-dobes commented 11 years ago

I believe it should be compatible - I could probably read the href via prop() either.

Majkl578 commented 11 years ago

I've been digging a bit and maybe found a root of the problem. The difference between .prop() and .attr() seems to be that prop returns absolute URL, even though it's set as relative. After doing what I said in first post (getting link by prop and putting it to another anchor), this then makes the following condition in validation extension to fail: https://github.com/vojtech-dobes/nette.ajax.js/blob/61ae5822922283869d75473555da4029f7d49773/nette.ajax.js#L308. (By the way, am I correct nette.ajax.js doesn't work with absolute URLs at all because of this?)

Edit: Yup, it seems when validation ext is enabled (by default), absolute URLs do not work at all. :/ (Changed the title of the issue.)