question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Call function of a javascript module

See original GitHub issue

First, I would like congrats for that awesome project and documentation. Nice job! I’m trying use django-unicorn on a project and based on examples I guess that have many functions on JavaScript maybe cause conflicts. There any possibility to call a javascript module function? Example:

  var Hellojs = (function() {
    var self = {};

    self.hello = function(name){
      alert("Hello " + name)
    }
    return self;
}());

  window.Hellojs = Hellojs;
class HelloView(UnicornView):
    name = ""

    def say_hello_in_js(self):
        self.name = ""
        self.call('Hellojs.hello', self.name)

Thanks, @adamghill and all contributors!

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

3reactions
adamghillcommented, Mar 20, 2021

https://www.django-unicorn.com/docs/changelog/#v0-25-0 has been released with this fix! 🎉

1reaction
nielsonsantanacommented, Mar 19, 2021

Thanks @adamghill, I tried this PR, but I didn’t have enough time. I hope contribute more soon. This PR will help a lot.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to call a function declared in a javascript module (type ...
First of all you have to explicitly export you function: export function greet() { alert("Hello from module"); }. Secondly, a module has ...
Read more >
JavaScript modules - MDN Web Docs
This guide gives you all you need to get started with JavaScript module syntax.
Read more >
How do I call a javascript function inside a JS module ... - Reddit
Typically with JS modules you would export the function from one module and then import it into another module to call it: greetings.js:...
Read more >
Modules, introduction - The Modern JavaScript Tutorial
A module may contain a class or a library of functions for a specific purpose. ... call functions of one module from another...
Read more >
JavaScript Modules – Explained with Examples
A module is a function or group of similar functions. They are grouped together within a file and contain the code to execute...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found