I am currently working on integrating a private chat feature using SignalR in my project, and I have encountered an issue while creating a View with accessible model values to pass to the server. Specifically, I have a list of doctors, and when a user clicks on a doctor's link, it should open a chat partial view for consultation. However, I am facing difficulties in utilizing the model's values from the partial view in the parent view's JavaScript code. Although there are suggestions on how to retrieve data from a partial view on Stack Overflow, I have also attempted to write JavaScript within the partial view using @section, but this approach is not permitted. As a solution, I am considering combining both models into one and using it in the parent view. For instance, when I click on a doctor's name, I want to update the values in the chatbox specific to that doctor and use those values in the JavaScript for chatting. Here is some of my Parent View code:
@model E_HealthCare_Web.ViewModels.ConsultationViewModel
<section class="chat-wrapper">
<!-- Code for doctor list goes here -->
</section>
<section class="chatbox-section">
<!-- Chatbox section code goes here -->
</section>
Below is the partial view where I'm trying to access the model values:
@model E_HealthCare_Web.ViewModels.ChatLoadViewModel
<!-- Partial view content here -->
Lastly, here is the JavaScript responsible for the chat functionality:
// JavaScript code for chat functionality goes here
Additionally, below are some controller methods and model classes used in this implementation:
//Controller methods and model classes code goes here
If anyone has suggestions or guidance on how to improve this implementation, please feel free to share your insights. Thank you!