WayneZ
WayneZ

Reputation: 13

Jquery editable plugin code not working

The basic usage of the plugin looks simple but it does not work for me. I am using Firefox and Chrome.

html code:

<div class="editable"> limited to 200 char my private messages</div>

js code:

 $('div.editable').click(function() { $this.editable();});

When I click the text inside the div on my page, nothing happens.

I viewed my source code and both jquery and editable JavaScript files are there.

What's wrong with my code?

Upvotes: 0

Views: 990

Answers (3)

James
James

Reputation: 79

Use $(function(){ ...your code goes here... }). Which jquery plugin are you using for editable? inline editor or https://github.com/tectual/jQuery-Editable and as it is said use $(this)

Upvotes: 0

SirViver
SirViver

Reputation: 2441

I believe you may want to call $('div.editable').editable() immediately (or in $(document).ready()) to mark the div as editable. The handling of going into edit mode upon clicking the div should be automatically done by the plugin.

Otherwise, after changing $this to $(this) you may have to click twice to enter edit mode for the first time. Or it might not work at all when repeatedly making the same element editable (which depends on how the plugin handles this scenario).

Upvotes: 1

Gal
Gal

Reputation: 5907

Try changing $this to $(this) - it needs to go through jQuery.

Upvotes: 1

Related Questions