Episodes
Alain Ravet said about 3 years ago on Creating a Gem From Existing Code :
No mention of what to do with the tests? That's the hard part: - how to run them, while developing the gem, AND - how to include them with the app tests suite when running on CI.

Simon Kiteley PRO said about 3 years ago on Creating a Gem From Existing Code :
Thanks for this. I think it might and been in response to my request so thank you. Having one issue in that I have a bit of code: ```
``` Where when the cursor exits the field the form is submitted by javascript (I also added a submit button and still have the issue) however it does not seem to be recognising the "remote: true". Any Ideas?

David Kimura PRO said about 3 years ago on Creating a Gem From Existing Code :
If I understand your question correctly, you may be looking for the `onfocusout` event. https://www.w3schools.com/jsref/event_onfocusout.asp Within the listener function, you would search for the parent form and submit it through javascript. It looks like you're trying to do an autosave which seems pretty cool and would make for a great episode as there are many approaches to this.

Simon Kiteley PRO said about 3 years ago on Creating a Gem From Existing Code :
Hi. Sorry for not being clear. My script is: ``` $("#question- .autosave input").blur(function() { // alert('----1----'); $("#question- .autosave form").submit(); // alert('----2----'); }); ``` And that seems to be working well. What is happening in the gem I have created but not the application I copied it from is that the "remote: true" on the form is being ignored and doing a 'normal' submit of the form. So: ``` ``` is behaving as if it was: ``` ``` Yes, it is quite cool in the original code I wrote as you get little save icon to show your changes have been saved etc. The code I am trying to put in a gem is a bit like SurveyMonkey on steroids. I guess is some way it is not 'attaching' the script to the remote bit. In the test/dummy I have: ```

First name:

Last name:

|
``` Which includes the questionnaire for the user. So probably something missing in the application.js: ``` //= require jquery //= require rails-ujs //= require activestorage //= require_tree . ```

Login to Comment