0

This is my controller code :

 doInit : function(component, event, helper) {
    var action = component.get("c.getpickval");
    var inputsel = component.find("InputSelectDynamic");

    var opts=[];
    action.setCallback(this, function(a) {
        for(var i=0;i< a.getReturnValue().length;i++){
            opts.push({"class": "optionClass", label: a.getReturnValue()[i], value: a.getReturnValue()[i]});
        }
        inputsel.set("v.options", opts);
        console.log($("#optionValue")[0]);
         $("#optionValue").hide();   
         $(".number").show();

    });

     //document.getElementById("optionValue").style.visibility = "hidden";

    $A.enqueueAction(action);       

},   

Here I want to hide optionValue div and show div with class named as number on my init handler. Now above error is resolved but still these hide and show functions of jquery are not working. I am using jquery 2.2.4

  • What is the name of your static resource? – Mohith Shrivastava Jun 13 '16 at 10:29
  • @ Mohith jquery224 – Raseeka Jun 13 '16 at 10:40
1

In addition Mohith's comment you may have a conflict with using the $ variable in Salesforce Lightning. You may want to use jQuery's noConflict function to remap the $ variable to something like $j. I know that noConflict re-mapping is usually needed on VisualForce pages which incorporate jQuery.

0

The correct tag will be

<ltng:require styles="/resource/slds090/assets/styles/salesforce-lightning-design-system.min.css" scripts="/resource/jquery224" />

You do not need any timestamp there .

  • Also it looks like the OP is trying to use $ inside the init handler,there might be timing issue too, which i thinks is the main problem.So it's better to use the afterScriptLoaded while trying to use $ or any 3rd part libraries. – Praveen Jun 13 '16 at 11:04
  • You might be correct .Hope the author of question posts some code .But the way jquery was referenced is also wrong . – Mohith Shrivastava Jun 13 '16 at 11:06
  • Hi @MohithShrivastava Thanks.. Now error has been resolved but jquery functions .hide() , .show() are still not working. – Raseeka Jun 13 '16 at 12:23
  • Please post full code so we help better – Mohith Shrivastava Jun 13 '16 at 12:27
  • I have posted full code @Mohit – Raseeka Jun 20 '16 at 5:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.