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

Using events is unclear #33

Open
dreadpiratebrown opened this issue Jul 3, 2013 · 3 comments
Open

Using events is unclear #33

dreadpiratebrown opened this issue Jul 3, 2013 · 3 comments

Comments

@dreadpiratebrown
Copy link

dreadpiratebrown commented Jul 3, 2013

I don't understand how to use the start and stop events with this plugin. I am trying to create a button that only shows while the Chardin overlay is active. On the "stop" event, I want to hide it. How do I do this?


Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

@rhyous
Copy link
Contributor

rhyous commented Jun 22, 2015

I agree. It seems we should be able to do this:

var onStop = function() {
// do something when chardin stops.
}
.chardinJs('start', onStop)

However, I can't a way to do something on stop either.

@rhyous
Copy link
Contributor

rhyous commented Jun 22, 2015

Looks like you can use jquery events:

$("body").on('chardinJs:start', function(){
  // on start
})

// 'chardinJs:stop'
$("body").on('chardinJs:stop', function(){
  // on stop
})

Also, here is a binding handler for knockout.js

ko.bindingHandlers.helpStop = {
    init: function (element, valueAccessor) {
        ko.utils.registerEventHandler("body", "chardinJs:stop", function () {
            valueAccessor().call();
        });
    }
};

ko.bindingHandlers.helpStart = {
    init: function (element, valueAccessor) {
        ko.utils.registerEventHandler("body", "chardinJs:start", function () {
            valueAccessor().call();
        });
    }
};

@patrickfitz
Copy link

Hi, what is the easiest way to get the element name when the "next" event it fired? I'd like to get access to this to perform things such as making hidden dom elements visible as the help items require...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants