Closed cfavila closed 11 years ago
Hi,
I'm not quite sure what the jQuery UI library is supposed to do or how you are using it, but based on the markup you posted I can make a couple of suggestions:
</body>
tag.$('#my_new_content').readmore(...);
Here's a quick example of how you could insert content and initialize Readmore on it.
<!DOCTYPE html>
<html lang="en" class="no-js">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<!-- <link rel="stylesheet"
href="css/jqueryui/jquery-ui-1.10.1.custom.css" type="text/css" /> -->
<style media="screen">
body { font: 16px/1.5 "Helvetica Neue", Arial, Helvetica, sans-serif; color: #444; }
code { color: #777; font-family: "Source Code Pro", "Menlo", "Courier New", monospace;}
a { color: #178DB1; }
</style>
</head>
<body>
<h3>Dynamically Added Readmore Example</h3>
<div id="dialog1">
<table width="550px">
<tr>
<td>
<b>Dynamically added content will appear below when you click this button: <button href="#" id="popup1">Make some content!</button></b>
</td>
</tr>
<tr>
<td>
<div id="etdesc"></div>
</td>
</tr>
</table>
</div>
<!-- <script type="text/javascript" src="js/jqueryui/jquery-1.9.1.js"></script>
<script type="text/javascript"
src="js/jqueryui/jquery-ui-1.10.1.custom.js"></script> -->
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.js"></script>
<!-- readmore js -->
<script type="text/javascript" src="readmore.js"></script>
<script>
$('#popup1').on('click', function(event) {
msg = "<p>Salvia portland leggings banh mi fanny pack mixtape,authentic bushwick wes anderson intelligentsia artisan typewriter high life they sold out mixtape high life. Marfa ethnic wayfarersbrooklyn keytar mixtape. Blue bottle shoreditch gluten-free,mixtape hoodie whatever pinterest viral twee fashion axe high life irony biodiesel tofu.</p><p>Retro church-key thundercats keytar, skateboard ironyselvage ethnic freegan banjo pour-over fixie. Raw denim fashion axeoke locavore disrupt, tonx retro authentic letterpress raw denimstumptown mixtape ugh kale chips flexitarian 90's deep v. Squid fingerstache bespoke wolf DIY. Banjo pour-over shoreditch cardigantry-hard.</p>";
$('#etdesc').html(msg).readmore({
speed : 1000,
maxHeight : 100
});
});
</script>
</body>
</html>
This work only one time. If change text after initializing readmore, plugin dont work
I am trying to use javascript to dynamically set the content of a div element for which the jquery readmore link is configured. This functionality does not appear to work. I may be way off based and completely missed something trivial here, but have spent hours... Any help is greatly appreciated.
I have created a prototype that illustrates this behavior. Please see the uploaded snippet