how to add class and id in codemirror - codemirror

i would like to add an id along with the class that codemirror adds.
does anyone know where to start with this?
the outcome i want is something like
<span id="1234" class="cm-cm-overlay cm-url">google</span>
<span id="3452" class="cm-cm-overlay cm-url">microsoft</span>
i know how to add the cm-url class with a custom mode, but how to i add an id on each line?
as to why i want to do this, i am working on a project that I need to link each particular line with a database record, i thought the id could be the linking field.
any ideas on where to start? i haven't found any documentation on it.

Related

Salesforce lightning:carousel

I am using the in the code the Html class name are not viewable.
but if I use inspect element I can find the HTML class name that it uses such as slds-carousel__content etc.
My problem is i cant access those class name on my client side controllers.
Is there a way to get those class name ?
Here is a link to that describes how to change the class. You can get the component by using component.find("insertnamehere").getElement(); It's not always reliable unless you are specifying a render attribute on the controller though.
https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/js_cb_show_hide_markup.htm
as a side note: as sanctimonious as some of the mods on the Salesforce stackoverflow might seem, it is still a more likely place to find such content. Good luck.

Custom VF Email Template is not recognizing my custom visualforce component as global

Hi All and thank you for taking the time to look at my question!
I created a custom vf component to query some information and send an email to a lead. Here is the component tag:
<apex:component access="global" controller="My_Component_Name">
Please note the attribute access="global".
In my VF Email Template I include the component as follows:
<c:My_Component_Name cust_field="{!relatedTo.Custom_Field__c}">
</c:My_Component_Name>
However, when I try to include this component in a VF Email Template, I get the following error:
Error: <messaging:emailTemplate> can only contain components with an access
level of global. <c:my_component_name> is not valid.
I tried waiting, in case there was a time lag, I tried deleting the content and resaving, I even tried cloning the component and including the cloned version. Nothing helps.
Does anyone have any ideas what I can do?
*I changed the names of the components and fields, so please don't comment on possible typos in the names.
Well, this is VERY embarrassing, but just in case someone else makes this mistake I will admit it:
I was working in two different orgs at the same time :( My component with access="global" was in sandbox and the VF template was in Prod.

MVC Default Edit View increments the id property of my model? Can't figure out why. .

I'm trying to learn web development, and I bet that this is a simple problem and that I'm overlooking something obvious.
In my default crud edit controller (generated using the MVC framework) I retrieve my model from a localDB instance using my EntityFramework's dbContext. That is sent to the View. In the debugger just before the controller call to return View(model) I can see that the Id is set to 2.
When the [post] edit controller is fired I see that the identity property is 3. I wanted to figure out why so I changed the View to display my Id property and I see that it is 3 as soon as I render the page. Last time I saw it the property was 2, now it is 3.
I don't know how to hook into any logic that would happen between the time I send off my model and when when the view is rendered.
Can anyone help me learn how to debug this so that I can figure out why my Id property is incremented when I pass the model into the view?
I don't know how EntityFramework works but I have worked with CakePHP. My advice is like this:
Usually PHP frameworks have debug mode which you can set in the configuration file (turn it on or off). Usually stack of operation executed is also displayed in debug mode or there is a simple way to do that. There's also for example in CakePHP exist function debug($yourVariable); try to search for sth. similar
It seams like not the edit happens but new row is inserted to the database. Check your database for this. I recommend to debug the id of the column being passed for edit action and check if there's the same id in the database first of all.
Hope something helps.
I figured it out. Posting here for anyone else that comes across my problem.
I tried dumping the whole model out without using any of the htmlhelper methods. (In my case I am uinging: Html.HiddenFor helper) When I did this I saw that the value in the model was what I expected it to be. So I began investigating why the helper methods might be broken. Google worked for me here :)
Turns out, when the helper methods run they first check the ModelState dictionary for the desired value. In my case I was looking for a value that was in my model object as well as the ModelState dictionary, because the name was very common: Id.
To fix the issue before I call return View(model) I call ModelState.Clear() in order to make sure there are no values in the dictionary that are in conflict. Doing this causes my page to be rendered correctly.

Custom Lift tags don't work

The following types of tags in Lift do not seem to work for me:
<lift:snippet type="MyClass:render" />
<lift:MyClass.render/>
<lift:MyClass/>
Using these tags results in a Class Not Found error. If I attempt to call a class using
<div class=lift:myclass.mymethod />
it can work. Or if I call it using span tags. For instance, the Hello World example in Pollak's Simply Lift works for me, successfully displaying the Howdy method with the following code:
<span class="lift:helloWorld.howdy">
Welcome to your Lift app at <span id="time">Time goes here</span>
</span>
Currently, my problem is coming from attempting to implement Exploring Lift's (aka The Lift Book) OpenID example in Chapter 13.1. I have downloaded OpenID4Java using sbt as well as the lift-openid library. That example can be found at http://exploring.liftweb.net/master/index-13.html. I have implemented the change to the Boot class, and created the OpenID class and the SimpleOpenIDVendor class. But creating an html file containing
<lift:OpenID.form>
<openId:renderForm/>
</lift:OpenID.form>
causes the following error to be displayed in the browser:
Error processing snippet: openid.form
Reason: Class Not Found
XML causing this error:
<lift:openid.form xmlns="http://www.w3.org/1999/xhtml">
<openid:renderform>
</openid:renderform></lift:openid.form>
The class OpenID was placed in a package that starts with the package code, which is being implicitly found by Lift. It is included in the Boot.scala file with the line
LiftRules.addToPackages("code")
So, I am at a loss. Any ideas?
Note that other lift tags such as lift:bind-at and lift:surround and the like work fine.
As dave posted under my original comment, the problem was the HTML5 parser. Lift is case-sensitive, and cannot find a class with varying case. Since the HTML5 parser automatically makes tags lowercase, you can't use custom lift tags anymore. Instead, you have to use something like
<div class="Lift:MyClass.render"></div>
Note that you CANNOT have
<div class="Lift:MyClass.render" />
as HTML5 apparently does not support such tags.
My OpenID4Java problem is therefore resolved by using:
<div class="lift:OpenID.renderForm">
</div>
Why I don't need to use openid.form still is uncertain. It could be possible I'm implementing it slightly off, but I confirmed that it will take me to an openid login page if I put in the openid link, so it is indeed functional.
Sources:
http://groups.google.com/forum/#!topic/liftweb/H-xe1uRLW1c
https://groups.google.com/group/liftweb/browse_thread/thread/3948df1eee6ec271/ (thanks fmpwizard)

How do you automatically set focus on a form field using yui

I currently have an issue where I want text field to be automatically selected when the user visits my webpage, I currently do this by Javascript but would, ideally, like to use YUI. After searching the web, i found this command,
YAHOO.util.Dom.get("first_element").focus();
and
YAHOO.util.Dom.get("text1t").focus();
but have had very little luck getting it to work, one suggestion was to use a setTimeout fnction, but this seems a rather ugly way of doing it.
If anyone has any suggstions I would be very grateful.
Thanks,
Try using onAvailable
YAHOO.util.Event.onAvailable("elementId", function(me) { me.focus(); }, YAHOO.util.Dom.get("elementId"));
You may need to use a later event, like onContentReady or even onDOMReady if that doesn't work.