Open full view…

Is there a way to catch if/show/hide action yet?

Tue, 13 Dec 2016 06:24:12 GMT

I need a function to execute when a tag 'shows' (not mount) in order to initialize a datepicker. Since the tag is already mounted but will be hiding until a user action takes place, the datepicker will not be able to find the DOM element that it must attach to. Does anyone have a work around for this issue?

Tue, 13 Dec 2016 07:22:56 GMT

Not ideal, but the solution I'm currently using is as follows: --- // app.js var shared_observable = riot.observable(); riot.mount('container', {observable: shared_observable}); // container.tag.html <my-tag observable={ opts.observable }></my-tag> <my-other-tag observable={ opts.observable }></my-other-tag> // my_tag.js this.add_new_debate = function() { emit_date_picker(self, opts); } function emit_date_picker(self, opts) { window.setTimeout(function() { self.opts.observable.trigger('create_picker'); }, 50); } //my_other_tag.js var my_date_picker; this.opts.observable.on('create_picker', function() { var config = { future: true, target: 'first-mtr-datepicker' }; my_date_picker = new datepicker(config); }) ---

Fri, 27 Jan 2017 00:21:12 GMT

have a look at the examples for a if/else virtual tag another user created

Fri, 27 Jan 2017 01:56:33 GMT

Thanks Vinstah. I was totally unawares of the `if` mount/unmount in Riot 3 and upgraded yesterday. This is exactly what I needed.