cta.js icon indicating copy to clipboard operation
cta.js copied to clipboard

feat: Add dynamic targeting on modal open/close action

Open iliketomatoes opened this issue 8 years ago • 1 comments

With the current version of cta.js, when we invoke the cta function, the second argument we pass must be an HTML element object (which represents the target).

With this new feature we can eventually use a function or either an array as a second argument. To make things work out we have to follow these rules:

  • If we use a function as the target argument, that function must return an HTML element object.
  • If we use an array as the target argument, that array must hold at least one value and can hold at most two values. The type of the values can either be an HTML element object or a function that returns an HTML element object. If a second value is present into the array, we are telling cta that we want our modal window to target a different HTML element when we close the said window. (This can be useful in some peculiar navigation patterns, I can provide an example if you ask).

I hope this can be useful for the development of this powerful and elegant plugin. At least it's been useful for me :-)

iliketomatoes avatar Apr 14 '16 08:04 iliketomatoes

See the working example at http://www.interpromotion.com/ , in the section "Works" . I made cta.js work together with a carousel. Hence the dynamic selection of the closing HTML element.

iliketomatoes avatar Jul 06 '16 06:07 iliketomatoes