Just one more question and I will always be grateful!
Suppose I require the data from bookId = 1 and want to display the attribute data in a Modal component (we can imagine the bootstrap), I would also like to change any value of any field, imagine the title of the book and save next.
In the code below, I'm just giving you an idea! Can you help me organize this code?
functionopenModal(){$("#form").modal({show:true});}functionobjectForm(){constid=document.getElementById('id');consttitle=document.getElementById('title');constauthor=document.getElementById('author');id.value=Store.BOOK.id;title.value=Store.BOOK.title;author.value=Store.BOOK.author;}// use to save start// function called by the save buttonfunctionsaveBook(){formObject();}functionformObject(){constid=document.getElementById('id');consttitle=document.getElementById('title');constauthor=document.getElementById('author');Store.BOOK.id=id.value;Store.BOOK.title=title.value;Store.BOOK.author=author.value;}// // use to save end// GET BY IDasyncfunctiongetBookById(bookId){constbook=awaitFetch.get('/books/'+bookId);Store.BOOK=book;//return book;objectForm();openModal();}
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Hello!
Suppose I create a BookController and have a function below in this controller:
Could I export this function to call it in another js file?
Another thing, is it possible to make the constant books a global variable and export that variable so that I can use it anywhere?
Yes, you can export it. Regarding global access, I like to create a new module for that. In my case, I called it Store.
I then include this in my modules whenever I need to access a global variable.
thanks for the return, it was of great help!
Just one more question and I will always be grateful!
Suppose I require the data from bookId = 1 and want to display the attribute data in a Modal component (we can imagine the bootstrap), I would also like to change any value of any field, imagine the title of the book and save next.
In the code below, I'm just giving you an idea! Can you help me organize this code?