Adamhumbug Posted December 18, 2019 Share Posted December 18, 2019 Hi, I have the following code that populates a modal $('#userDeleteConfirmationModal').on('show.bs.modal', function(event) { // Button that triggered the modal var button = $(event.relatedTarget) //data elements var userid = button.data('userid') var activesheets = button.data('activesheets').split(", ").join("\n") console.log(activesheets); var modal = $(this) modal.find('#deleteUserConfLabel').text(userid) modal.find('#active-sheets-label').text('This user has the following active sheets') modal.find('#active-sheets').text(activesheets) the console log outputs Job 1 Job 2 but the text.(activesheets) shows them on the same line when they hit the page. Any ideas? Quote Link to comment https://forums.phpfreaks.com/topic/309705-split-string-into-new-lines-at-comma-update-text/ Share on other sites More sharing options...
Barand Posted December 18, 2019 Share Posted December 18, 2019 You need "<br>" for newlines in an html document ("\n" and multiple spaces are ignored unless between <pre>..</pre> tags or in a <textarea>) Quote Link to comment https://forums.phpfreaks.com/topic/309705-split-string-into-new-lines-at-comma-update-text/#findComment-1572616 Share on other sites More sharing options...
Adamhumbug Posted December 18, 2019 Author Share Posted December 18, 2019 1 hour ago, Barand said: You need "<br>" for newlines in an html document ("\n" and multiple spaces are ignored unless between <pre>..</pre> tags or in a <textarea>) when i use <br/> it echos that exactly. A new event<br/>Chelsea's Event Quote Link to comment https://forums.phpfreaks.com/topic/309705-split-string-into-new-lines-at-comma-update-text/#findComment-1572620 Share on other sites More sharing options...
Barand Posted December 18, 2019 Share Posted December 18, 2019 What is the object whose id = active-sheets? Quote Link to comment https://forums.phpfreaks.com/topic/309705-split-string-into-new-lines-at-comma-update-text/#findComment-1572622 Share on other sites More sharing options...
Adamhumbug Posted December 18, 2019 Author Share Posted December 18, 2019 Just now, Barand said: What is the object whose id = active-sheets? it is a p tag Quote Link to comment https://forums.phpfreaks.com/topic/309705-split-string-into-new-lines-at-comma-update-text/#findComment-1572623 Share on other sites More sharing options...
Barand Posted December 18, 2019 Share Posted December 18, 2019 try the html attribute instead of the text attribute modal.find('#active-sheets').html(activesheets) 1 Quote Link to comment https://forums.phpfreaks.com/topic/309705-split-string-into-new-lines-at-comma-update-text/#findComment-1572625 Share on other sites More sharing options...
Adamhumbug Posted December 18, 2019 Author Share Posted December 18, 2019 1 minute ago, Barand said: try the html attribute instead of the text attribute modal.find('#active-sheets').html(activesheets) Thats the one!! Quote Link to comment https://forums.phpfreaks.com/topic/309705-split-string-into-new-lines-at-comma-update-text/#findComment-1572626 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.