Connect tinyMCE to knockout.js

Learn how to utilize tinyMCE custom binding using.

    public sealed class CabinetShapeEditModel
{
    public string Description { get; set; }
}

When implementing in the view:

    <script type="text/javascript">
    var jso = @Html.Raw(Json.Encode(Model));
    var viewModel = ko.mapping.fromJS(jso);
</script>

The HTML structure:

<div style="min-height: 250px; padding-left: 10px; padding-top: 5px;">
          <textarea data-bind="wysiwyg: Description, wysiwygConfig: {selector:selector, menubar:false, statusbar : false, height: 210, toolbar: 'undo redo | styleselect | bold italic | link unlink | image | media | charmap| code | table | ltr rtl | emoticons | forecolor backcolor | fullscreen | preview', plugins: 'hr,link,image,charmap,preview,code,fullscreen,insertdatetime,media,table,directionality,emoticons,textcolor'  }"></textarea>
</div><script type="text/javascript">
    ko.applyBindings(viewModel);</script>

For JavaScript implementation, refer to: https://github.com/michaelpapworth/tinymce-knockout-binding

If encountering the following error: Uncaught TypeError: Unable to process binding "wysiwyg: function (){return Description }" Message: Object [object Object] has no method 'tinymce'

What could have been incorrectly executed?

Answer №1

If you're seeing the error message "Object [object Object] has no method 'tinymce'", it likely means that you forgot to include the plugin jquery.tinymce.min.js. I've made updates to the documentation to address this issue.

Answer №2

Consider the following suggestions:

  1. Instead of using the compressed version, try including the debug version of the wysiwyg binding
  2. In your developer tools (Chrome Dev Tools or Firebug), navigate to the Scripts panel and set a breakpoint on line 57

    $(element).text(value).tinymce(defaults);
    

After setting the breakpoint, reload the page to trigger the debugger before the error occurs.

The $(element) should represent your textarea, while value should be your Description. While the dev tools have paused at the breakpoint, open the Console and manually execute these steps to check for any unexpected results:

$(element)
$(element).text(value)
$(element).text(value).tinymce(defaults)

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

I am encountering an issue where the $scope.modal is returning as undefined when attempting to open an Ionic template modal. What

I am currently developing an Ionic application for the iPad. Within one of my templates, I have implemented a treeview with items. My goal is to open other templates modally when users click on these items. However, I encountered an error stating that $sco ...

After a successful transactWrite operation using DynamoDB.DocumentClient, the ItemCollectionMetrics remains unpopulated

Currently, I am utilizing a transactWrite instruction to interact with DynamoDb and I am expecting to receive the ItemCollectionMetrics. Even though changes have been made on the DynamoDb tables, the returned object is empty with {}. Does anyone have any ...

Loading data with limit offset in AngularJS can lead to controller functions crashing and causing data to become jammed

I have developed a video gallery application similar to Youtube using AngularJS. The application includes a REST API which is accessed through Angular services. There are two controller files in the application with similar functionalities but calling diff ...

Mixing controllers with the same name in AngularJS from different modules can lead to

Recently, while working on an AngularJS web application with multiple sub-modules, I encountered a situation where two sub-modules had controllers with the same name due to them both having CRUD functionality. Here's a snippet of the code structure: ...

Notify other viewers that a button has been activated

I'm working with a basic HTML file that contains two buttons. When one of these buttons is pressed, I want to notify another user in some way within a few seconds. <html> <body> <input type="button" value="Button 1"& ...

The content is not wrapped when transferred from App.js through props, although it is being wrapped in other scenarios

As I work on developing a basic invoice generator application, I encounter an issue with overflowing content in the "notes" section when passing data through props from the App.js file. Instead of wrapping the text, it overflows its container. import "./Ap ...

Creating a carousel of cards using JavaScript, CSS, and HTML

Here is a visual reference of what I'm attempting to achieve: https://i.stack.imgur.com/EoQYV.png I've been working on creating a carousel with cards, but I'm struggling to synchronize the button indicators with card advancement when clicke ...

Customizing an array.map display in React Native

For my app, I am creating multiple drawers to showcase how it can be used. This is done by using the following code: Array(400).fill(info).map(info => {return <AlbumBox info = {info} />}) The information of an object is retrieved and passed into ...

In Redux, it is possible to add characters to an array but for some reason the remove action does not successfully reach the reducer

As a user types or erases characters, I am utilizing redux to update an array of characters. This allows me to set a success flag when the user correctly types the entire phrase. Currently, when typing in characters, the SET_INPUT action in redux fires of ...

Console.log is displaying array as [object Object] when utilizing Typescript

When working with an object in typescript called "obj," I encountered a strange behavior. Initially, when I ran the console.log(obj); command, the output in the terminal console was displayed as [object Object]. However, after wrapping it in JSON.stringify ...

The output of an Angular factory function is consistently null

I am facing an issue with storing the currentUser object in a factory to make it accessible throughout my app. Despite ensuring that the user object is being received server side, whenever I call CurrentUserFactory.GetCurrentUser(), it returns null inste ...

JavaScript providing inaccurate height measurement for an element

Upon loading the page, I am trying to store the height of an element. To achieve this, I have utilized the jQuery "ready" function to establish a callback: var h_top; var h_what; var h_nav; $(".people").ready(function() { h_top = $(".to ...

employing iframes dynamically to overlay a webpage

I inserted this iframe into a webpage <iframe src='http://redbug.redrocksoftware.com.au:80/Pages/chamara.html' style="position:absolute;z-index:1;" ></iframe> The chamara.html page has a button that, when clicked, should cover the c ...

Switch between Light and Dark Modes effortlessly with just one button

I've created a code that effortlessly switches between light mode and dark mode with the press of buttons. However, I'm looking to combine these two functionalities into a single toggle button for ease of use. If anyone can provide insight on how ...

Exploring the magic of VueJS: Implementing computed properties for "set/get" functionalities in tandem with Vue.Draggable and

Currently, I am in need of assistance with utilizing "Vue.Draggable". For the past two days, I have been struggling to properly update the draggable array. The main challenge lies in: Updating the draggable array using computed set/get functions Obtaini ...

Generating fresh objects to establish a Many-to-Many connection with Sequelize

I am currently utilizing NodeJS, Express, Sequelize, and PostgreSQL in my project. Within my application, I have defined two models: a "User" model and a "Social" model. My goal is to establish a many-to-many relationship where a user can be associated wi ...

Utilizing API calls within a loop using AngularJS

I need to execute a series of APIs in a loop, but I want the second loop to start only after receiving the result from the last API call in the first loop. How can I achieve this? for(var i=0; i<array.length; i++ ) service.getfunction(array[i]).t ...

Retrieving text data in Controller by utilizing jQuery AJAX request

Text box and button for input <input type="text" class="form-control" name="ClaimNumber" placeholder="Enter a claim number" id="ClaimNumber" /> <button class="btn btnNormal" type="submit" id="btnSearch"> ...

What are your thoughts on the practice of utilizing the useState hook within a component to send data to its parent component?

I have been working on developing an Input component that can be dynamically used in any page to store input values. The component also includes an attribute called getValue, which allows the parent component to access the input value. In my App.js file, I ...

Change PHP code to a JSON file format

I am currently learning Laravel and my current focus is on how to send a JSON file from the back end to the front-end. I intend to utilize this JSON data to generate a graph. Within my model, I have created a function that retrieves values and timestamps ...