Questions tagged [mithril.js]

Mithril.js is a client-side MVC framework.

Mithril.js is a client-side MVC framework - a tool to organize code in a way that is easy to think about and to maintain.

Some features include

  • Safe-by-default templates
  • Hierarchical MVC via components
  • Virtual DOM diffing and compilable templates
  • Intelligent auto-redrawing system

Official page and resources: http://mithril.js.org/

260 questions
2
votes
2 answers

Get component in event handler like config functions do

What's the correct approach to accessing a component in an event handler? Or, what should I be doing instead? I have a UI section that is essentially a div-button. When the user clicks it, then the "button" is replaced with an input. When the user…
Eric Majerus
  • 1,099
  • 1
  • 12
  • 23
2
votes
1 answer

Mithril components - bounded controllers

I have a mithril component with an controller which is already bounded to an context, if I use m.component(), mithril disregards the bounded controller and supplies the view with an default empty controller UserWidget = function(){ this.allUsers =…
chifer
  • 683
  • 5
  • 19
2
votes
1 answer

m.request: Determine specific cause of XHR Failure?

Question When mithril's m.request fails with a timeout or a network error, the error returned is simply null. This makes it impossible to distinguish between timeouts a lack of internet connection other kinds of errors. Is there a way to…
Jonah
  • 15,806
  • 22
  • 87
  • 161
2
votes
1 answer

How to check if mithril.js is loaded?

I'm trying to create a local fallback for loading the mithril.js file in case the CDN fails. I want to use the aquivalent of this jQuery fallback:
Marcus
  • 822
  • 1
  • 8
  • 27
2
votes
1 answer

mithril rendering "background-image url"

I have the following issue with mithril Image is display properly when it is a proper img tag `` But same image not rendered at all when it is set as …
Hiran
  • 698
  • 1
  • 10
  • 29
2
votes
3 answers

Nesting HTML in a string with mithril

I would like to generate the following HTML with Mithril's m:

I am a person

. I'm currently using m.trust for this: m.trust("

I am a person

"). But I don't like the HTML string. Is there a better way to do this?
Lask3r
  • 137
  • 1
  • 1
  • 6
2
votes
1 answer

How do you format an AJAX request to an API with an authentication key using Mithril?

The following GET request works using jQuery: $.ajax({ url: "https://yoda.p.mashape.com/yoda?sentence="+phrase, headers: {"X-Mashape-Key": "superSecretKey", "Accept": "text/plain"}, success: function(data) { console.log(data); …
Salman Oskooi
  • 366
  • 3
  • 8
2
votes
1 answer

Mithril js , Is there any good method for m.request() loop and concat Array?

See below. https://jsfiddle.net/z30y983n/1/ First, the script gets 4 items from Github API and renders a list. If you submit 'NEXT' button, the script re-draws the list after re-sends Get request. GET request. repo.Repo.getList = function (api) { …
2
votes
1 answer

Set time out event on a m() generated element

I have a m("p.help") element which is removed with a click event. I also want the element to be removed automatically after a few seconds if not clicked. I need to set a time out on it. Setting time out does not work. function help() { var text =…
r.sendecky
  • 9,933
  • 9
  • 34
  • 62
2
votes
1 answer

History and XHR issues with Sails running on localhost

With the default configuration, I am unable to make XHRs in my Mithril app if I run its Sails server in localhost. All I get is: XMLHttpRequest cannot load http://localhost:1337/json/test-realms.json. The 'Access-Control-Allow-Origin' header…
amyspark
  • 520
  • 1
  • 4
  • 15
2
votes
1 answer

Mithriljs: prevent full application reload on submit

I have a single component which is just a login form. When login is unsuccessful I get a full application reload for some reason. This is the application main entry. All it does is the initial authentication ping. If session is up it loads the…
r.sendecky
  • 9,933
  • 9
  • 34
  • 62
2
votes
2 answers

Mithril.js: Should two child components talk to each other through their parent's controller?

I'm a bit stuck looking for the right way to do the following. I have a parent component with two child components (see simplified code below). I would like to know the proper way for ChildA, when its button is pressed, to 'invoke' ChildB. They…
Berco Beute
  • 1,115
  • 15
  • 30
2
votes
3 answers

Mithril: render component on event/dynamically

Trying to get the hang of Mithril, can't really understand one thing. Can I render components on events? Let's assume I have one parent component: var MyApp = { view: function() { return m("div", [ m.component(MyApp.header,…
2
votes
1 answer

Mithriljs does not update DOM on change in data

I read somewhere, the DOM is updated every time an event occurs and there is changes in data which are bound to DOM. So I wished to learn more about it. I tried the code below but the DOM is not updated when data in textarea changes but its updated…
learner010
  • 445
  • 5
  • 17
2
votes
1 answer

MithrilJS: How to get XHR.status on error and data on success with m.request()

I need to receive http status errors with m.request so I use extract as per documentation. But it messes up my data return for some reason. According to docs, if I use extract to get status then extract return is passed as a parameter to the error…
r.sendecky
  • 9,933
  • 9
  • 34
  • 62