262 questions
0
votes
0
answers
48
views
How to efficiently toggle components using Mithril.js
I have a list of some data. I want to display and edit that data.
My Home component iterates over this data and display using Item component it Each row has data and edit button. After clicking on ...
0
votes
1
answer
52
views
Mithril app crashing when open multiple tabs/popups
I'm working on a project using Mithril, and on a table whenever I click an element it opens a popup Component which is basically composed by 4 divs nested into each other and the deepest one is ...
1
vote
0
answers
53
views
Certain Formatting Options No Longer Work, mithril js, quill js, quillRenderer, sass
Our company's site utilizes typescript, Mithril js, Quill JS, (also quill renderer), and sass. Certain styling options that worked before changing to the quill renderer have stopped working. The ...
0
votes
1
answer
98
views
Mithriljs add onkeydown event when component is created
I am trying to initialize an onkeydown event when a component is created:
var KeyboardComponent = {
parse: function(e){
console.log("pressed: " + e.key);
},
view: ...
1
vote
0
answers
300
views
Mithril js framework, enable hot reload?
I am using Mithril javascript framework with Vite bundler. Application is really complex and during debugging, for every change (even a small HTML edit), it takes me like 10-20 seconds to get to the ...
0
votes
1
answer
287
views
Mithril JS input checkbox events and element refresh
Working on a SPA with Mithril.js (love it!), but having a problem with input checkboxes not behaving correctly when I assign an "onchange" listener to them.
var Widget = {
view: function(...
0
votes
1
answer
98
views
using return of async function in view()
I previously had a simple component that looked something like this, but previously the getIsLoggedIn method was synchronous. We recently had to change that method to async, so I tried adding the ...
1
vote
1
answer
773
views
Google Publisher Tag Reward Ad reloads Mithril SPA unexpectedly
When I run this code in my localhost server and I click the Show Ad button in the #!/reward page, the reward ad shows but sends me back to the #!/ page. However, in this online code editor this SPA (...
0
votes
2
answers
249
views
Typescript requires mithril import that breaks in javascript
Currently translating my javascript app to typescript. Previously I was just using m() and Vnode without any imports, but typescript wants needs to include import m, { Vnode } from 'mithril'; so it ...
0
votes
0
answers
89
views
Async function FileReader issue - console.log() array works fine but shows length as 0 [duplicate]
async function parseFile(file, type) {
const fileSize = file.size;
const chunkSize = 1024 * 1024; // bytes
let offset = 0;
let chunkReaderBlock = null;
const hash = sha1.create();
const ...
1
vote
2
answers
131
views
Recursive Mithril View function - not rendering further
Here is a DisplayComment function. I want to make a comment thread. Basically a reply structure kind of thing. Each parent comment is displayed in the table and I want to render its replies just below ...
2
votes
1
answer
218
views
Getting a NodeList of the HTML tags in Mithril
Is there a way of having a NodeList of the HTML tags in Mithril? I need to get the width of the blocks. Something like that on vanilla js:
const blocks = Array.from(document.querySelectorAll('.blocks')...
0
votes
1
answer
156
views
Map 2 arrays in Javascript
I'm trying to display the content of 2 arrays of contained in an object.
When I map RType.information.Type the content of the array "Type" is displayed.
But nothing happened if I want to ...
1
vote
1
answer
266
views
render a canvas in mithril
how can i render a canvas inside mithril ?
here is my typescript code :
import * as mithril from 'mithril';
import m from 'mithril';
import * as PIXI from 'pixi.js';
var root = document.body
// The ...
1
vote
0
answers
204
views
Mithrill Error TS2344: Type 'State' does not satisfy the constraint 'Lifecycle<Attrs, State>'
I am new to Mithril. I am trying to follow this example for a pretty basic start: https://github.com/spacejack/mithril-ts-example. Here are my package.json, and tsconfig.json :
# package.json
{
&...
0
votes
2
answers
310
views
How to redraw specific DOM asynchronously in Mithril
I have sub-components that are updated by injecting state from the parent component.
I need to populate the model using an asynchronous function when the value of the parent component changes.
And I ...
0
votes
2
answers
563
views
Setting an attribute dynamically in mithril.js
I'd like to set an attribute in mithril.js inside the oninit function. For example,
m('img', {
oninit: (vnode) => {
vnode.attrs.src = 'A url string';
}
})
I want to check for ...
0
votes
1
answer
321
views
How to use another js in mithril.js
I need to include a third-party js library in my website and a working example in plain HTML file is something like
<div id="app"></div>
<script src="app.js"></...
0
votes
1
answer
482
views
Codemirror doesnt style code from textarea
I can't get a solution from this.
an help will be appreciated
import CodeMirror from "codemirror";
export default class RealTimeEditor extends Page {
view() {
window.onload = ...
1
vote
2
answers
850
views
Why does the Mithril child component state change not trigger an update?
The following code works as expected: it creates two counter buttons that persist their state and update on clicking:
let Counter = function (vnode) {
let count = 0
return {
view: (vnode) =&...
-1
votes
1
answer
519
views
Having issue of rendering Mapbox map from any ID other than "app"
I'm trying to implement Mapbox gl gs into a project I'm building with Mithril and am having issues with getting a map to render from any ID other then "app". Within the body of my html I ...
0
votes
1
answer
340
views
How to trigger onchange event in an IFrame mithril element when a codemirror editor in the srcdoc of the IFrame changes?
Let's say I have a HTML called post.html that has a codemirror editor in it. the post.html looks something like:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js&...
0
votes
2
answers
245
views
Returning empty object from POST request (mithril w/ Node and Express)
Currently having an issue where a object with null values for all content except ID is returned when trying to complete a POST request from my front end. I'm also not receiving any error messages in ...
1
vote
1
answer
140
views
How does Mithril component work here is some weird experience I had
I was going through documentation and I ran following code in script.js
var Article = {
view: function(vnode) {
console.log(vnode)
return "This is article " + vnode....
0
votes
1
answer
242
views
Why is the state overwritten by the attributes in the latest instance for all instances of a component when using IIFEs with Mithril.js?
I'm trying out Mithril.js and have made three small components.
let Map = (function() {
let Map = {};
let parent;
Map.oninit = function(vnode) {
parent = vnode.attrs.parent;
}
...
1
vote
1
answer
81
views
JS function result not rendering
I'm trying to render the result of the function renderVerticalCards, but nothing is returned in the DOM, other than the outer divs (those from outside the function call). I have confirmed through the ...
1
vote
1
answer
390
views
Using Mithril.js, how can I add options given by an async function, to a previously added select element
I'm trying to add options to a previously created Vnode (select element).
The element is returned before the options are available, since they come from an async function.
Although I try to set the ...
0
votes
2
answers
910
views
Mithril: how to use multiple root elements?
When using m.route, does everything under it have to be rendered using Hyperscript (not counting JSX)? Is it possible to mix pure HTML with multiple separate parts rendered using Hyperscript?
Suppose ...
3
votes
2
answers
306
views
Error `Template parameter names *must* be separated`
I am using mithril.js in frontend application and backend application is running on ipv6 environment.
Calling post ajax request to backend using mithril.js.
async post(url, body = {}) {
return ...
0
votes
1
answer
219
views
Prevent duplicates created by Mithril while sorting elements with SortableJS
I am making an dahboard creator tool. Dashboard is set of rows, each row have boxes. So I trying to make list of lists of items. Items can move between lists. Lists can be sorted between each other.
...
0
votes
2
answers
436
views
JSX Curly Braces Inside Script Tag?
This is a silly question but it's stumped me for a while now. I'm currently trying to design a Mithril.js component that returns a <div> object that includes a <script> tag. I've just ...
0
votes
1
answer
281
views
How to incorporate D3 svg elements into mithril.js?
I have been working with a framework using mithril.js and wish to add this script that draws an interactive tree into a component on my website.
So far, I just placed the JS code inside the script ...
0
votes
1
answer
109
views
Why is creating a new array instead of emptying the old one causing a problem here?
I'm working on a project in Javascript and hit a problem that I don't understand.
Basically I've written a map generator that is generating maps from noise, that bit is fine and working.
I want the ...
0
votes
1
answer
543
views
In mithril.js, onremove and onbeforeremove events not firing, while oninit and oncreate are
File TodoApp.js:
...
const Todo = {
oninit(vnode) {
...
// ok
},
oncreate() {
...
// ok
},
onbeforeremove() {
...
// not firing
},
onremove() {
...
// not ...
0
votes
1
answer
481
views
simple bar plot with mithril.js and d3.js
I am very very new to javascript and mithril.js. I am trying to create a very simple bar plot using mithril.js and d3.js. But, I am not having any luck even getting the axis in place.
Firstly, I ...
0
votes
1
answer
640
views
How to disable button in after click in mithril.js to prevent multiple clicks
I was able to disable the button after click but the page is not getting submitted, it just got disabled.
How can I submit the page and prevent it from multiple clicks in mithril.js?
m(".submit", m("...
0
votes
1
answer
1k
views
Updating component with async function in mithirl.js
I'm trying to get some initial data for a component using an async function oninit then updating
that component each time 'Show more' button is clicked.
Here is the component:
const Listings = {
...
0
votes
1
answer
509
views
How to force Mithril to redraw without diffing? (integrating dragula in Mithril)
I am translating a JQuery-based app to Mithril. That app uses Dragula to allow drag/drop to reorder lists.
Dragula reorders the li elements in the DOM.
When the Drop event is fired, I sync the model ...
0
votes
1
answer
137
views
How does one create a function to call itself when a given condition is true in Mithril.js
This is my mithril code:
m('input', {
id: 'someBox',
placeholder: 'Type something',
oninput: () => {
query = document.getElementById('someBox).value;
//do something
...
1
vote
2
answers
1k
views
How to use 'value' of input tag in mithril.js
I want to be able to store the value of the text inputted in a variable. I thought something like would work:
m('input', {
placeholder: 'Type to search...',
oninput: () => { alert(this....
0
votes
1
answer
89
views
Mathjax won't reload when using mithril mount function
I am using Mithril and am dynamically mounting some content. the first time the page loads everything works fine. Once I click a button, which causes one thing to unmount and another to mount, the ...
0
votes
1
answer
903
views
Using Mithril.js, why does my onclick handler not modify the mithril component?
I am making a quiz web app. I have a class called an "answerBox", which currently just contains a button, an ID, and a Boolean. I want to call a "check Answer" function that determines if my answer ...
0
votes
1
answer
52
views
Security Concerns with m.trust()
I'm trying to use a diff library in order to log edit histories of user posts for my page. That library gives me a long JSON data for diffs to store in my database and i am using the same repository's ...
0
votes
0
answers
133
views
How to propagate message to children on a Mithril Widget
I have a mithril ListWidget that displays a list of Items. The icon you see on the right allows to expand and collapse the details. It is a field "expanded" in each Item vnode state.
Now I want to ...
0
votes
0
answers
199
views
Preventing component redraw Mithril + ChartJS
I'm trying to draw in a canvas created in a Mithril's component. My problem is that I don't want this component's view to be redrawn when the application needs. I found that the onremove/oncreate ...
1
vote
1
answer
413
views
Configuring webpack, babel and mithril.js
I'm trying to get webpack and babel working (I'm new to both). When I run the webpack-dev-server compilation goes fine but content from my imported module isn't working. Here is how I configure my ...
3
votes
2
answers
1k
views
Event capture on mithril?
is there no event capturing?
Id like to force event handling order, in autocomplete component, onblur event fires before onclick on item in a list, causing the list to toggle twice and so remaining ...
0
votes
1
answer
306
views
How to encapsulate state with an update method and a mithril component
I want to render state that is updated every request animation frame.
I want to encapsulate state with an update method and corresponding component:
But that fails because it's not correct usage of ...
0
votes
1
answer
252
views
share data between two files through es6 class in mithril js or share instance of es6 class
I want to share data between two files in mithril js Im using webpack for module loading I have this class , Im getting data from ajax request and then storing it in class member given below.
import ...
0
votes
2
answers
832
views
load json file before app startup and save it in global variable mithrilJs
I want to load a JSON file into my mithrilJs app before its startup and want to save this data in some global variable (JSON file is for some run time configuration of mithril application just like ...