Hi!
I haven't tried that specific combination yet, I usually use buttons for
onclick events. However, I think this should work:
var mydiv = createTiddlyElement(place, "div", "myID");
mydiv.onclick = function(your,params) {your function}
w
On Tuesday, December 6, 2016 at 11:52:13 PM UTC+1, Hiru Yoru wrote:
>
> Hi, w,
>
> Thank you very much for your reply. It was very helpful! I was able to use
> the methods you mentioned with much success.
>
> May I ask, how could I create a <div> element and specify onclick
> behavior for it? Is that possible?
>
> Thank you again,
> Hiru
>
> On Sunday, December 4, 2016 at 3:03:55 AM UTC-5, whatever wrote:
>>
>> Hi!
>>
>> Since all your three segments above are supposed to end up as a single
>> item, you can just concatenate, like you did in your
>> someFunctionToRenderHTML
>> example. And you can use wikify, but you need to also state the second
>> parameter, namely where to wikify. You also need to escape and double
>> quotes. Note the difference between classname and someText below. classname
>> is part of the string and its tags are escaped (here you can also use
>> singular quotes (') instead of escape double quotes (\")). someText is a
>> variable that you're inserting into the string, hence not only the double
>> quotes but the pluses on either side.
>>
>> var someText = "Some text goes here.";
>> var out = "<span class=\"classname\"><h1>Header</h1><br />"+someText+"<br
>> /></span>";
>> wikify(out,place);
>>
>> So basically, no need to wikify each element separately.
>> Also note the "place" parameter. This is the location of where you stuff
>> will be rendered, namely at the location where your plugin call is located
>> in the tiddler, taking into account any CSS that makes it otherwise. If
>> you've used the createTiddlyElement function to create a specific div, span
>> or whatever, you can also render into that element.
>>
>> var mydiv = createTiddlyElement(place, "div", "myID");
>> var out = "<span class="classname"><h1>Header</h1><br />Some text goes
>> here.<br /></span>";
>> wikify(out,mydiv);
>>
>> The above code works within a plugin, but if you're using script tags,
>> you need to specify the place separately. Which we'll deal with separately,
>> if necessary.:)
>>
>> w
>>
>>
>> On Saturday, December 3, 2016 at 9:59:33 PM UTC+1, Hiru Yoru wrote:
>>>
>>> Hi,
>>>
>>> I have a few questions that I searched the group for, but I couldn't
>>> find clear answers to:
>>>
>>>
>>>
>>> *When writing a plugin...-- How do you render html code into a tiddler
>>> efficiently?*
>>>
>>> I tried using wikify(), but even when it succeeded in rendering html
>>> tags, it enclosed them in an unnecessary span. I'm not looking to only
>>> render an empty element. I'm looking for how to render something with the
>>> content that goes within it.
>>>
>>> For example:
>>>
>>> someFunctionToRenderHTML("<span class="classname"><h1>Header</h1><br
>>> />Some text goes here.<br /></span>");
>>>
>>>
>>>
>>> *-- How do you render part of an html tag in one place and then part in
>>> another?*What if I wanted to render part of a span before some code and
>>> then the closing tag to the span afterwards. For example:
>>>
>>> <span class="someclass"> // render this individually
>>>
>>> // code goes here
>>>
>>> </span> // render this closing tag individually
>>>
>>> Is there a way to do this?
>>>
>>> I looked at existing plugins and just wasn't able to decode things. Any
>>> help that you could provide would be greatly appreciated!
>>>
>>> Kind regards,
>>> Hiru
>>>
>>
--
You received this message because you are subscribed to the Google Groups
"TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit
https://groups.google.com/d/msgid/tiddlywiki/bda7a08f-05b3-4cce-b095-346c5c58e169%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.