I'm trying to update an input field value .ckfinder-input
via ck finders pop up image selector. It all works fine until I try and assign the selected image URL to the input field input.val() = fileUrl
and get the following error message:
ReferenceError: invalid assignment left-hand side
Could someone shed some light on what I'm doing wrong?
My code is as follows:
$(".ckfinder-modal-button").on("click", function() { input = $(this).parent().find(".ckfinder-input"); BrowseServer(input); }); function BrowseServer(input) { var finder = new CKFinder(); finder.selectActionData = input; finder.selectActionFunction = function(fileUrl, data) { input = data['selectActionData']; console.log(input); //returns Object[input.form-control.ckfinder-input property value = "" attribute value = "null"] console.log(fileUrl); //returns "/customer_images/header_images/home.jpg" input.val() = fileUrl; // ReferenceError: invalid assignment left-hand side; } finder.resourceType = 'HeaderImages'; finder.removePlugins = 'basket'; finder.popup(); }
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> <div class="bootstrap-filestyle input-group"> <input type="text" class="form-control ckfinder-input" name="ckfinder-input"> <span class="group-span-filestyle input-group-btn ckfinder-modal-button" tabindex="0"> <label class="btn btn-default"> <span class="icon-span-filestyle fa fa-cloud-upload"></span> </label> </span> </div>
probably it's because your JavaScript is invalid. You cannot assign a value ( fileUrl
) to the output of function ( input.val()
) in: js input.val() = 'abc';
You should either:
a) if it is DOM Input Element : input.value = 'abc';
b) if it's jQuery wrapper for DOM Element : input.val( 'abc' );
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.