Tag: javascript

  • Symfony 5+ how to view dump output with AJAX requests

    Symfony 5+ how to view dump output with AJAX requests

    So the idea is to be able to use the Symfony VarDumper component to be able to dump values when sending an AJAX request and view them for debugging while in development mode, but not in production mode. Create a new directory To do this you will need to create an event subscriber and listen […]

  • Javascript and contenteditable how to move the cursor to the end of user input

    Javascript and contenteditable how to move the cursor to the end of user input

    This appears to work in all browsers. Let me know if you find issues. So this is something I needed to do and all the examples I found didn’t work properly. Or they worked partially, or only in one browser. The idea seems super simple, but in reality the problem becomes complex for several reasons. […]

  • Javascript event listeners be careful where you bind this

    Javascript event listeners be careful where you bind this

    In Javascript User interface programming you often need to work with EventListeners. In modern Javascript you may also be doing this in a class, which is handy. One of the  things that sucks about Javascript event listeners is they eat memory and slow your app down, if you are not REALLY careful. They do this […]

  • How to view Symfony 5+ FosJsRoutingBundle routes

    How to view Symfony 5+ FosJsRoutingBundle routes

    I can never remember this command. However, now that I am creating more AJAX and exposing endpoints I need this command more often. This command is found in the docs too. But I can never remember where, so I will write about it here. The command to view how FosJsRoutingBundle views your routes. php bin/console […]

  • Symfony how to get query string values sent by AJAX calls

    Symfony how to get query string values sent by AJAX calls

    When using a Symfony API endpoint for getting values such as maybe something like an auto-complete feature you will need to be able to send some text(what the user enters) to the backend. Then have the backend return a response based on that. For example with an auto complete feature, you might want to send […]

  • Faking Enumerations with Vanilla javascript

    Faking Enumerations with Vanilla javascript

    What is an Enumeration? An Enumeration is a way to create a limited list of options to choose from.This is useful for keeping a list of field names for a form so you can use javascript to animate something for example. Having a limited list of options is helpful so that you can eliminate bugs […]

  • Symfony 5+ how to include page specific javascript or css when using Webpack encore and SASS

    Symfony 5+ how to include page specific javascript or css when using Webpack encore and SASS

    In this article I will cover how to do this with Webpack in Symfony with CSS and SASS. This is slightly confusing. Symfony has it’s own Webpack configuration called encore. Read that documentation article if you need more info, more links at the bottom of the page. Webpack Config First lets checkout the file app\webpack.config.js […]

  • How to make AJAX requests to Symfony 5+ controllers

    How to make AJAX requests to Symfony 5+ controllers

    I couldn’t find anything in the documentation about this and there is little on the internet about it too.  There is probably a Bundle somewhere for this or some Symfony way, but I didn’t find anything. I did find this SymfonyCast about submitting a whole form. If you need to test your Controller route read […]

  • How to get URL Routes in your Javascript in Symfony 5+

    How to get URL Routes in your Javascript in Symfony 5+

    This article has been recently updated to fix errors. Do not miss the last step. If you are using an EventSubscriber to store the last page the user visited or else Symfony redirects your users to the routes after they register. In the Symfony docs it shows you how to get a URL to your […]

  • How to create and use a custom Javascript Event

    How to create and use a custom Javascript Event

    You have probably used events in Javascript many times.  Especially if you have done any User Interface programming. There are many types of events provided by browsers and the Javascript engines. Did you know you can create your own custom events with the CustomEvent() constructor? Here is a minimal example. In this article I will […]