eelkenet Posted October 21, 2019 Share Posted October 21, 2019 I just found out my fancy Float (Range) slider does not work with Repeaters, unless I disable AJAX for the repeater. This is because I pass the Inputfield's settings to the JS side of it through the $config->js route. For every field I use the unique settings of that field. On the InputField I set these accordingly: $otherFields = $this->config->js('InputfieldFloatRange') ? $this->config->js('InputfieldFloatRange') : []; $this->config->js('InputfieldFloatRange', array_merge($otherFields, [ "Inputfield_" . $this->attr("name") => [ 'precision' => $this->get("precision"), 'rounding' => $this->get("roundingMethod"), 'displayValueField' => $this->get('displayValueField'), 'min' => $this->attr("min"), 'max' => $this->attr("max"), 'step' => (float) $this->attr("step") ] ])); And retrieve them on the Javascript side: function getSettings(id) { return window.ProcessWire.config.InputfieldFloatRange[id]; } var settings = getSettings(event.target.id); // from a 'change' event on the slider However, when I create a new repeater item, it does not append that items slider's settings to the ProcessWire.config object, as I would have expected. I could use an alternative path (using data-attributes in the actual field), but would prefer to keep this neatly. So, does anybody know what I need to do to append my Inputfield's settings to $config->js dynamically, ie. upon creating a new repeater item (with AJAX)? Link to comment Share on other sites More sharing options...
Robin S Posted October 21, 2019 Share Posted October 21, 2019 You need to pass your settings to $config->js() in a renderReady() method.https://github.com/processwire/processwire/blob/7d4ca45673152436ea492b6577341ee3550e2821/wire/core/Inputfield.php#L1224-L1244 3 1 Link to comment Share on other sites More sharing options...
eelkenet Posted October 22, 2019 Author Share Posted October 22, 2019 Thank you very much @Robin S, I have been able to fix the issue! ? 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now