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

Jquery closest/find selector support #56

Closed
Pandahisham opened this issue May 24, 2015 · 10 comments
Closed

Jquery closest/find selector support #56

Pandahisham opened this issue May 24, 2015 · 10 comments

Comments

@Pandahisham
Copy link

sometimes in list items it is helpful to have a descentant class selector for target instead of id , something like ic-target ="find .description"

@Pandahisham
Copy link
Author

oops descendant

@ThisNoName
Copy link

You mean like this? Works fine.

<button id='ping' ic-post-to='/ping' ic-target='#result > .second'>Ping</button>

<ul id='result'>
    <li>test1</li>
    <li class='second'>test2</li>
    <li>test3</li>
</ul>

@webholics
Copy link

I have the same problem. In my opinion intercooler relies too heavily on defining unique global ids for DOM elements. This may work for small examples but not for complex cases where you may have lots of the same ajax components on the same page.

In my option all selectors used in Intercooler attributes should per default not be global but restricted to the children of the current element. And only if you really want to have a global selector you could put the keyword "global" in front of the selector.

Another thing which really frustrates me is that not all selectors are handled equally e.g. I can use "closest" on ic-target but not on ic-indicator.

@adaniello
Copy link

In doc you can read "attribute should be a valid global CSS/JQuery selector OR the string closest followed by a space, followed by a valid CSS selector, which will be evaluated as the closest parent matching the given selector".
And, as @whoever123 said, any "valid global CSS/JQuery selector" works fine.

@webholics
Copy link

Yes but that is not my point. My point is that I want not a global selector ($(selector)) but a lokal one ($(selector, el)).

@adaniello
Copy link

Can you use "closest" reserved word (eg "closest div.modal-content")?
Or remember that the attribute may be placed on parent elements.

@adaniello
Copy link

Why not post a codepen sample?

@webholics
Copy link

This is my case http://codepen.io/anon/pen/avRrbe

Its just the markup. My problem is that this is a component which is in use multiple times on the page and I don't want to create artifical unique id attributes for .voting or .voting__progress just to be able to select them.

@adaniello
Copy link

@webholics, i don't understand well what is your problem, but if you have multiple ".voting" blocks, everyone with its progress, take a look at http://codepen.io/anon/pen/rOqgeb (css is only for sample).
I hope this can help you

@1cg
Copy link
Contributor

1cg commented Nov 9, 2015

Hi webholics. I can see your point, generating unique IDs in repeated UX is ugly and annoying. It seems like a sane algorithm would be to try the selector first as a find() from the current element, then as a global selector.

I will try to get something along those lines in the next release.

@1cg 1cg closed this as completed in 6e93d04 Nov 17, 2015
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

5 participants