question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Apply hooks locally

See original GitHub issue

Hooksare currently applied globally. If I write something like that $.fn.selectric.hooks.add('Init', 'placeholder', setPlaceholder); all other selectric instances are affected.

Wouldn’t it be better to allow hooks to be applied per instance? What was the original thought to implement this function? The Event-System is relatively similar, isn’t it?

const select = $('select').selectric();
const hooks = select.selectric('hooks');

hooks.add('Init', 'placeholder', setPlaceholder);

#140

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
laphilosophiacommented, Apr 19, 2017

here. fixed it.

$('.fixed-label').selectric({
  onInit: function( element, obj ) {
    const select = $(element);
    const placeholder = select.data('placeholder');
    const wrapper = select.closest('.selectric-wrapper');
    const label = wrapper.find('.label');
    if ( label.text() !== placeholder ) {
      label.text(placeholder);
    }
  }
});
1reaction
gearsdigitalcommented, Sep 28, 2016

If you want I can remove the hook-stuff… Have some spare time right now 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

Git Hooks | Atlassian Git Tutorial
Git Hooks are scripts that run automatically every time a particular event occurs in a Git repository. Learn what they do and how...
Read more >
Git Hooks - Git SCM
You can use these hooks for all sorts of reasons. Installing a Hook. The hooks are all stored in the hooks subdirectory of...
Read more >
How to Use Git Hooks? - Hostinger
How to Use Local Hooks · Open your repo's . · Find the sample file of the hook you want to use. ·...
Read more >
Git Hooks | Learn how to use pre-commit hooks, post-commit ...
An introductory guide and resource for Git hooks. Learn how to use pre-commit hooks, post-commit hooks, post-receive hooks, and more.
Read more >
pre-commit
Git hook scripts are useful for identifying simple issues before submission to code review. ... For example to use python3.7 for language: python...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found