Modal HTML structure makes it kind of hard to use #2040
-
Hey there, I've been working with Fomantic UI for a little bit now, have talked to a colleague of mine and we were both kind of puzzled by the HTML structure of the Modal. It is entirely possible that coming from other UI frameworks we're trying to make it do something it's not meant for. This is why I'm submitting this as a discussion. Our environment is a hybrid one with pages using Fomantic UI and others that don't. Combining these UIs requires using iframes while we migrate the remaining UIs to Fomantic. Additionally, we load editors (i.e. HTML forms) rendered on the server when they are required via AJAX to display them in Modals. In both use-cases, we run into the issue that the Modal likes to have its buttons in an This makes the Modal pretty hard to layout for. For the forms we have used the work-around to join the Modal with the form into a Just as a thought - it would be easier if the styles for the bottom Any suggestions or thoughts? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
Some (untested) ideasTell the action buttons to submit an independent formWhile the action buttons do not belong to a form inside the content node, you can of course tell them to submit the independent form when you click on them prior to close the modal $('body').modal({
actions: [{
text: 'Submit',
class: 'ok',
click: function(){
$('#myform').form('submit'); // FUI Form behavior OR
$('#myform').submit(); // native form submit OR
// submit the form inside the iframe
var myIframeDoc = document.getElementById('myiframe').contentWindow.document;
myIframeDoc.getElementsByTagName('form')[0].submit();
}
}]
}); Wrap the modals children into a formThis will make the modals sizing independent of the forms sizing <div class="ui tiny modal">
<form class="ui form">
<i class="close icon"></i>
<div class="header">
Modal Title
</div>
<div class="content">
<div class="ui input">
<input type="text" name="myname">
</div>
</div>
<div class="actions">
<button class="ui submit button">Submit</button>
</div>
</form>
</div> Style the form inside your iframe and call a JS function from the main windowIn your html which is loaded in the iframe, also style include fui css to style the form and ALSO add submit buttons, but DONT apply any action buttons to the form from the main html file.
|
Beta Was this translation helpful? Give feedback.
Some (untested) ideas
Tell the action buttons to submit an independent form
While the action buttons do not belong to a form inside the content node, you can of course tell them to submit the independent form when you click on them prior to close the modal
Wrap the modals children into a form
This will make the mo…